954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Double Click and Context Menu Error

Hey guys,
I have a TreeView in which i am usign the DoubleClick event handler.
The first time i double click on the grid (this happens everytime the grid is repopulated as well)
the event does not register. For example if i double click on a checkbox (single click will not due anything as i have the BeforeCheck event handler cancel the event ) but the double click still checks it yet the DoubleClick event does not register the first time.
The second time and everytime after that it will register it.
I also have a similar problem with right click and context menu. The first time i right click nothing happens but everytime after that the context menu is launched.
I am thinking it might have to do something with jsut in time compiling but i have never seen anything like this before. Anyone have any ideas on what it could be?

nnobakht
Light Poster
47 posts since Nov 2006
Reputation Points: 10
Solved Threads: 1
 

Can you show some code? its possible its not doing it when you think..

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 
//Two Event handlers.

		private void treeView3_BeforeCheck(object sender, TreeViewCancelEventArgs e)
		{
			e.Cancel = true;
		}

		private void treeView3_DoubleClick(object sender, EventArgs e)
		{
			Console.WriteLine("Double Click");
		}

//folowing is in initializeComponent();
this.treeView3.DoubleClick += new System.EventHandler(this.treeView3_DoubleClick);
			this.treeView3.BeforeCheck += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeView3_BeforeCheck);
nnobakht
Light Poster
47 posts since Nov 2006
Reputation Points: 10
Solved Threads: 1
 

Hmm, Im wondering, if perhaps it shouldnt be in initializeComponent, but, after, maybe in form load..

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 

I tired putting it into form Load but it still does the same thing. Its just weird how it only does this on the first double click and after that it works everytime.

nnobakht
Light Poster
47 posts since Nov 2006
Reputation Points: 10
Solved Threads: 1
 

sounds like it needs debugging sounds like its not being set the way you think.

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 

Correct. I cant see the reason why it is not though i have debugged step by step going through everything using breakpoints and stepping through it.

nnobakht
Light Poster
47 posts since Nov 2006
Reputation Points: 10
Solved Threads: 1
 

Id suggest zipping your code, uploading it somewhere so we can take a look.

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 

This is a known bug in the treeview control. It has existed since 2005, and is known to occur for projects running under Vista with visual styles enabled.

The only real workaround is to create a wrapper class for the treeview control and discard the double click event.

Would include links to microsoft references of the bug, but can't put them here. Google bug id 358695. Might also google 092fe0a3-073c-46d6-8d4b-10ddf7329526

wilsotc
Newbie Poster
1 post since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You