|
For one, I did not say you should override the OnPaint method (always override the OnEventName methods when deriving instead of handling the events in your derivitive class, but be sure to call base.OnEventName at the proper time). Because the WM_PAINT message works a little differently for the TreeView (and for the ListView too, for that matter), overriding OnPaint won't completely work. It is used to notify the TreeView that different elements need painting.
Also, if you really must change the default behavior of the tree (and you really shouldn't - keeping a consistent interface across the window manager, the majority of applications, and your own application is important for user friendliness), you could override the OnMouseDown method, check to see which mouse button is down, then see if there's a TreeNode under the cursor, setting it as the selected node:
protected override void OnMouseDown(MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
TreeNode node = this.myTreeView.GetNodeAt(e.X, e.Y);
if (node != null)
this.myTreeView.SelectedNode = node;
}
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have a DataAdapeter.Fill that takes a very long time. I was wondering if there was a way of telling how much is finished. I looked into the class using Reflector but couldn't find anything promising. Anyone have any ideas on how this can be done?
|
|
|
|
|
dear Ak ,
alse i have the same problem with update function it may take time more than fill function according to the changed data in the dataset so if you get any solution for this could you please tell me about it
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
Is the delay because of the amount of rows that you are returning, or due to processing on DB box?
Cheers,
Simon
sig :: "Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards
|
|
|
|
|
The delay is related ot the ammount of rows which is returned for the database
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
I would then suggest looking at the DataReader object instead in this case.
Cheers,
Simon
sig :: "Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards
|
|
|
|
|
This is for reading data from the server but what about updateing data to the server you should use the update finction in dataAdapter or you have to write similar function which check the changed data in the dataset to update it and check the deleted data to delete it and check for the new data to add it to the server!!!
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
Simon's suggestion is a good one. The DataAdapter actually uses DbCommand s and DataReader s (where applicable) internally. Everything you can do with the DataAdapter can be done with the other two classes I mentioned. Just make a DbCommand for the SELECT (use a DataReader here), INSERT (with option SELECT afterward), UPDATE, and DELETE commands and execute them accordingly, i.e. enumerate the rows, check the DataRow.RowState property, and execute the appropriate DbCommand .
You should get a good decompiler like .NET Reflector[^] and see how the DataAdapter (specifically, a derivitive class like SqlDataAdapter ) works internally.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
Marc Clifton wrote:
Is there some benefit to that?
Hmm, not sure about this one, however in all actuality it is best to do the following:
string s = "Nick";
if(s.Length != 0)
MessageBox.Show(s.ToString());
Because the compiler will emit less MSIL in relation to string.Equal(...); . Check this out on the FxCop Rule Topic[^] for System.String.Length .
- Nick Parker My Blog
Last time I checked, all programmers have selective ignorance. I know nothing about 3D graphics. I know a lot about COM. VB gets under people's skin because one can be ignorant of computer architecture and ASM and still get a lot done. - Don Box
|
|
|
|
|
But...
Be careful with .Length because if the string reference is null, you will get an exception.
string s = "Nick";<br />
<br />
if(s != null && s.Length != 0)<br />
MessageBox.Show(s.ToString());
|
|
|
|
|
Correct, specifically a NullReferenceException which is documented in the link I included with my post to Marc.
- Nick Parker My Blog
Last time I checked, all programmers have selective ignorance. I know nothing about 3D graphics. I know a lot about COM. VB gets under people's skin because one can be ignorant of computer architecture and ASM and still get a lot done. - Don Box
|
|
|
|
|
I don't think so. Just checked the IL and apparently
string a = string.Empty;
creates 1 more IL code than
string a = "";
As for any benefits, well, not to my knowledge. Maybe String.Empty is more readable than "" ?
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
It's a weird Life
|
|
|
|
|
Brad Abrams said
"" Actually creates an object.
String.Empty does not.
Thank You
Bo Hunter
|
|
|
|
|
so this means that String.Empty is actually more beneficial?
|
|
|
|
|
Marc Clifton wrote:
Is there some benefit to that?
Marc, FYI, here is the IL between the two (not a whole heck of a lot of difference, huh):
string s = "";
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
.maxstack 1
.locals init (string V_0)
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ldstr ""
IL_000b: stloc.0
IL_000c: ret
}
string s = string.Empty;
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
.maxstack 1
.locals init (string V_0)
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ldsfld string [mscorlib]System.String::Empty
IL_000b: stloc.0
IL_000c: ret
}
- Nick Parker My Blog
Last time I checked, all programmers have selective ignorance. I know nothing about 3D graphics. I know a lot about COM. VB gets under people's skin because one can be ignorant of computer architecture and ASM and still get a lot done. - Don Box
|
|
|
|
|
I agree with Bo.
Using String.Empty returns a "const" string object, so you will be refereing to the same object instead of creating another. Performance wise I wouldn't lose sleep over something like this.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Marc Clifton wrote:
Is there some benefit to that?
Last tid bit Marc, I was just watching MSDN TV where they talk to the CLR team that created FXCop and they discuss the reason for not using "". You can view this here: Code Correctness with FxCop[^].
- Nick Parker My Blog
|
|
|
|
|
|
Does any one know how to set the color of a scroll bar in XP and make it independent of the XP theme settings?
Lloyd Kreuzer
|
|
|
|
|
Hi,
How do I call WMI to access a remote system's information, such as disk storage and registry keys?
Any pointers will be greatly appreciated.
Thanks.
Sue
|
|
|
|
|
um... "Add Refrence" to the System.Managment dll, then conduct a search of these message boards for an array of various answers. That is as much as I feel safe to answer at this time.
have a nice day.
/\ |_ E X E GG
|
|
|
|
|
I'm such a smart ass. I'm probably wrong though. Actually, I bet I am...
Why do I even post this stuff....
sorry for wasting your time. I bet you got all excited, "YEAH!, somebody knows the answer to the problem I'm been trying to fix for DAYS..."
but no. it's just my incoherent ramblings and missspelled words.
/\ |_ E X E GG
|
|
|
|
|
Sue,
Please check out Windows Management Instrumentation (WMI) Implementation[^]; it should answer your questions.
- Nick Parker My Blog
Last time I checked, all programmers have selective ignorance. I know nothing about 3D graphics. I know a lot about COM. VB gets under people's skin because one can be ignorant of computer architecture and ASM and still get a lot done. - Don Box
|
|
|
|
|
Thanks Nick and Eggie 5 for the info.
Yes, I did find it from using WMI for accessing remote disk information, and I was able to use RegistryKey.OpenRemoteBaseKey() to get the remote system's registry key info.
Sue
|
|
|
|