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?

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

//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);

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

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.

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

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.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.