|
how do I have a machine refresh the user policies? I know there's a registry key to do this, but it seems to me there should be a better way, as the system doesn't even rescan that key often enough to know how often to refresh policies.
2ndly: how do I send text to a textBox on the next line of the textBox, without deleting any previous data in it.(this is a multiline textBox) (I'd prefer to not have to send previous contents to a variable and then insert them, as there should be a better way). also, is there a way to add the line numbers to each row of text in a text box.
thanks a bunch,
Stephen
|
|
|
|
|
check out the documentation on secedit.exe, this should allow you to update the Group Policies on a particular machine.
|
|
|
|
|
I couldn't get the thing to refresh my policy settings on my own machine even after changing them with gpedit.msc (I tried disabling regedit and the control panel). this didn't even work plus, I need to be able to incorporate these commands into my c# app. (I don't know how to use the command prompt via a c# program).
|
|
|
|
|
In order to force the refresh of Group Policies, you can call the API functions, defined in UserEnv.dll, RefreshPolicy or RefreshPolicyEx.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
incorporating the comand into your C# app is easy.
Just use the Process class. It has a static method Process.Start("command here") where the string represents the executable to run.
|
|
|
|
|
I have a few questions about Excel automation.
I've added a reference to the 9.0 Excel lib.
1. I'm able to automate Excel quite well but the instance of it will not close when I call the Application.Quit() method as in the following code:
ArrayList ToList = new ArrayList();
Excel.Application XLS = null;
Excel.Worksheet wsWorkSheet = null;
try
{
XLS=new Excel.ApplicationClass();
XLS.Workbooks.Open(FilePath,0, true, 5, "", "",
false, Excel.XlPlatform.xlWindows, "",true, false, 0, true);
...
...
}
finally
{
wsWorkSheet=null;
object missingValue = Type.Missing ;
if(XLS!=null)
{
XLS.ActiveWorkbook.Close(false,missingValue,missingValue);
XLS.Quit();
}
XLS=null;
}
Once my entire application closes the Excel instance closes but not when I call the Quit() method and set the instance varaible to null like I would expect it to.
2. At one point I allow the user to view the Excel Workbook currently being processed, it there any way I can catch the Excel close event, so the user cannot close the instance of Excel ?
3. Finally I was wondering if anyone had a simple way to tell if data is present in a particular WorkSheet. Right now I'm attemping to check the first 10 row of every sheet to see if there is data in them, but I suspect there is an easier way. Can I also interogate the WorkSheet for which Columns are in use ?
|
|
|
|
|
Hi,
I have a window written in a 4GL running, it uses a c# program to handle it's windowsmessages. On WM_PAINT I want some extra painting to happen (after the 4GL default). Just before the extra painting, I need some properties from the 4GL window.
I have seen ocx's used in the 4GL, you can choose ocxevents in the 4GL editor which you can edit, these events can have input, output and ref parameters. Do you have a (short) example of how to write such an ocx (with an event as described)?
I suppose this way of getting info into C# from the 4GL is to be preferred above socketcommunication?
regards,
Stefan.
|
|
|
|
|
I have a text file which contains different properties of a class (like integers, doubles, integer-array (more numbers divided by commas),..)
I want to read and assign.
Well, i managed to read all the key=value Pairs in that textfile and the looping through all the properties of that class. Now I want to assign these values to their appropriate property of the class.
But how can i convert now the values (which are logically strings) to the datatype they have to be?
I need something like
object Convert.FromString(string str)
Or I compare the read in keys with the properties from the class so that I know to which Datatype the string has to be converted, but on this way I need a way to typecast dynamically.
|
|
|
|
|
See the System.Convert class for dynamic casting and the System.Reflection namespace for reading the return type of properties.
|
|
|
|
|
object System.Convert.ChangeType(object value, Type conversionType, IFormatProvider provider);
|
|
|
|
|
that's what i was searching for
thanks
|
|
|
|
|
Hi,
Ive tried a Datagrid datasource bound to a dataview and dataset. I click on the header and it sorts the grid, which i want. After this i want to get the value in the first row, first column of the new datagrid before it has been drawn. Before I sort the grid i get the value either by getting it from the datasource or the dataview and it is what I want. Now i try to get the value after the sort and it gives me the same value as before the sort was done. Ive tried to bind the new dataview after programatically sorting it and getting the value, but with no luck. Please help.
My aim before was to override the Paint method and color the rows I want a different colour. So i need to check the value before it paints.
|
|
|
|
|
There are two different methods that can be used to do this. (Please be sure to check MSDN on the datagrid to get more details about both).
I color the column (not a row) that has just been sorted in an "OnItemCreated" procedure. I check to make sure the item is an Item or an Alternating Item and then I get the back color like this:
e.Item.Cells[m_iSortColumnIdx].BackColor = (System.Drawing.Color) new ColorConverter().ConvertFromString("#CCFFCC");
The other procedure you can use is the "OnItemDatabound" procedure. Again, you have to check to make sure the item is an Item or an Alternating Item.
From this method, you can access each of the cells and a number of attributes for that cell: text, back color, fore color, alignment, columnspan, class, etc. So if you know the column number (zero-based), you can also get the text.
Here's how I format my social security numbers in my very first column of my datagrid.
e.Item.Cells[0].Text = Utils.FormatSocial( (string)DataBinder.Eval(e.Item.DataItem, "social_num") );
I believe if you wanted to color the whole row, you might need to loop through each of the cells and set the color in the loop. (From what I remember of trying to do this in the past, this is how I had to change the style class or the color for an entire row).
You might also try 4 Guys From Rolla which is running an EXTENSIVE examination of the datagrid. You might find some discussion of these methods in that set of articles. The latest is # 17.
Pegmeister
|
|
|
|
|
hi,
Thanks for the help. I will try this out, its something I can do after my grid has been paited but I still need a way of getting the row information before the grid has been painted. What I do is check if something exists in the row and if it does I color it a certain color. My problem is that the paint method has the row number as a parameter but when I get the row from the Datasource bound to the grid using this row it doesnt give me the row that actually displays. This happens after I click the column header to sort the grid.
I cant cast the CurrencyManager Source and check its details because it only shows information for a specific cell in the row (I think its GetValueAtColumn(Source, RowNum)). I need to check the 1st column in that row and determine what colour to paint the cell.
|
|
|
|
|
Hello !
I am about to develop a decisional application that would display a huge amount of data (that is to say cells of grid).
The main principle of this project is that we have one column per day (an horizontal calendar grid in fact) and several rows below displaying different numerical or graphical informations.
We can of course display another range of dates by using the left and right arrow keys for example in order to move by one day (+1 or -1).
Furthermore we must implement a clean usability with navigation, scrolling, collapse/extand of certain rows, painting with mouse on certain rows and so on...
I can be provided with the data that are to be displayed in the shape of a dataset (one ROW per day) or of a custom XML stream.
The amount of data is so large that the grid(s) will cover an entire 1024x780 screen with around 30 visible days.
Now here is my question :
I wonder how to model this application in order to obtain a fast display (not flickering for example) and a easy to use application.
Must I reverse the dataset to get the days as columns and then databind it to the grid ?
Must I implement a collection of instance of a custom Day object and painting over the grid ?....
Please help me so that I will not have to rewrite all my code in a few month ....
Thank you in advance for all pieces of advice !
Guim7
|
|
|
|
|
I have the following code
void StopServices(serviceName){
try{
ServiceController svc = new ServiceController(serviceName);
svc.Stop();
svc.WaitForStatus(ServiceControllerStatus.Stopped);
}
}
catch (Exception){
}
My Questions are:
(1) I am using svc.WaitForStatus(ServiceControllerStatus.Stopped); (no time out defined here, coz I don't know how long the service takes to stop...), I think there is a possibility that the code will be blocked forever here, right? just waiting , waiting for the "Stopped" status..How can I avoid this?
(2) In terms of excepion, what kinds of exceptions may occur when controlling a service, what I can think of is "access right exception", what else?
Thank you!!!
|
|
|
|
|
ipsoftware wrote:
(1) I am using svc.WaitForStatus(ServiceControllerStatus.Stopped); (no time out defined here, coz I don't know how long the service takes to stop...), I think there is a possibility that the code will be blocked forever here, right? just waiting , waiting for the "Stopped" status..How can I avoid this?
You answered your own question here. Yes, if there is no timeout, the call can be blocked forever if the service crashes or hangs in some way. The way around this is to set a timeout, say 15 seconds?, when you create the ServiceController object.
ipsoftware wrote:
(2) In terms of excepion, what kinds of exceptions may occur when controlling a service, what I can think of is "access right exception", what else?
Just look at the documentation for each method of the ServiceController class and you'll find the list of exceptions that each method can throw. This is on top of all the security related exceptions that can be thrown. For instance, the .Continue method can throw a Win32Exception and a InvalidOperationException.
ServiceController Methods[^] documentation.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I'm writing a smart device application for a pocket PC using C#.
I need to make a terminal for the outside communication and I'm using a TextBox for this terminal.
Problem is: every time I try to add text to the terminal I do the following:
textBoxTerminal.Text += (string)TextToAdd; //1
textBoxTerminal.Select(textBoxTerminal.Text.Length,0); //2
textBoxTerminal.ScrollToCaret(); //3
I have to do 2 and 3 since after 1 the caret jumps to the beginning of the text.
Is there anyway to stop the caret from jumping to the beginning of the text every time text is added?
Thanks.
avivhal
|
|
|
|
|
Hi all,
Will using prepared statement improve the transaction speed of the database operation ?
Thanks
|
|
|
|
|
Yes, becase the database does not have to do as much work as when it is executing "ad-hoc" sql statements (i.e. non prepared).
Store your favourite bookmarks online: my-faves.co.uk
|
|
|
|
|
|
<homer>mmmmmmmmm white c# cod
You may want to phrase this a little differently, eg what you have tried, which particular thing you are stuck on.
|
|
|
|
|
Anyway cod is overfished, so white c# haddock would be better
or maybe c# mackerel, a tasty fish yet somewhat ignored in todays high level language restaurants
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
Any remotely useful information on my blog will be removed immediately. There are 10 kinds of people in the world. Those who have heard of the ubiquitous, overused, worn-out-like-an-old-shoe binary "joke" and those who haven't.
Judah Himango
|
|
|
|
|
Reminds me of the Kip Addotta song, Wet Dream:
...but she said things I just couldn't fathom. She was too deep. Seemed to be under a lot of pressure... I said "let's get tanked." She said "Not tonight, I got a haddock." And she wasn't kidding either, beacuse in came the biggest meanest looking haddock I'd ever seen come down the pike. He was covered with mussels. He came over to me, he said "listen shrimp, don't you come trollin' around here." What a crab. This guy was steamed...
Matt Gerrans
|
|
|
|
|