[Mono-list] WinForm TreeView Control

Stifu stifu at free.fr
Sun Jan 17 09:07:48 EST 2010


Sorry for the spam, I rushed too much. Now it's all clear to me.

EhlMenu is your TreeView, and as I said, you're attaching your
EhlMenu_NodeMouseDoubleClick method 4 times to the NodeMouseDoubleClick
event of this same TreeView.
The fix is very simple: take that last loop code line (the one where you
attach the event) out of the loop, so it's only executed once.
Alternatively, you could have attached the event from the designer (assuming
you're on using MonoDevelop, which has no WinForms designer), which is
what's usually done.

I'm still confused about how you add your Nodes to your TreeView, though, as
you don't do it in this loop.
Shouldn't you also do EhlMenu.Nodes.Add(newNode) at the end of the loop?


Stifu wrote:
> 
> PS: looking more closely at your code, I don't know what "EhlMenu" is
> supposed to be, but it doesn't change for each loop iteration. Ie: you're
> attaching the event multiple times to the same object. So that could
> explain your issue (and so it wouldn't be a Mono bug).
> 
> 
> Stifu wrote:
>> 
>> I don't know whether what you described is a Mono bug or not (did you try
>> with .NET? If so it's worth filing a bug with a test case), but you could
>> try doing it this way instead: handle the DoubleClick event of the
>> TreeView (not of the nodes), and in it, check which node is the selected
>> or hovered node (if any).
>> That way, you don't need to attach more than one event.
>> 
>> 
>> Rıdvan Tülünay wrote:
>>> 
>>> Hi,
>>> I am using, TreeView Control on my form,
>>> I wrote doubleclickevent on it,
>>> problem is on event occurs times,
>>> in my TreeView element has four node, events occur for four times,
>>> but I clicked only one node.
>>> 
>>> my code,
>>> 
>>> foreach (DataRow dRw in ehil_dataset.Tables["sismenu"].Rows)
>>> {
>>>                 TreeNode newNode = new TreeNode();
>>>                 newNode.Text = dRw["UYGISMI"].ToString();
>>>                 newNode.Tag = dRw["UYGKODU"].ToString();
>>>                 EhlMenu.NodeMouseDoubleClick += new
>>> TreeNodeMouseClickEventHandler(EhlMenu_NodeMouseDoubleClick);
>>> }
>>> 
>>> _______________________________________________
>>> Mono-list maillist  -  Mono-list at lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-list
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/WinForm-TreeView-Control-tp27198772p27199087.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list