I have a TreeView in which the nodes represent more complex objects. There
are several levels of objects (Parent/Child/GrandChild/GreatGrandChild) with
a different type of underlying object at each level.
I would like the users to double click on a TreeNode to edit the underlying
object. This works fine for editing (I'm trapping the DoubleClick event to
show an edit form). My problem is that in double-clicking on the tree, the
TreeView control interprets the double-click as a request to expand or
collapse the branch of the tree. I'd prefer things just stay put.
Any way to bypass this? (By the way I'm planning on using a
context-sensitive menu to expand / collapse the TreeView).
Thanks.
BBM
>I have a TreeView in which the nodes represent more complex objects. There
>are several levels of objects (Parent/Child/GrandChild/GreatGrandChild) with
[quoted text clipped - 12 lines]
>
>BBM
private void treeView1_BeforeExpand(object sender,
System.Windows.Forms.TreeViewCancelEventArgs e)
{
e.Cancel = true;
}
private void treeView1_BeforeCollapse(object sender,
System.Windows.Forms.TreeViewCancelEventArgs e)
{
e.Cancel = true;
}
private void treeView1_DoubleClick(object sender, System.EventArgs e)
{
MessageBox.Show("It works");
}
Leon.
Leon Friesema - 29 Nov 2004 21:14 GMT
>>I have a TreeView in which the nodes represent more complex objects. There
>>are several levels of objects (Parent/Child/GrandChild/GreatGrandChild) with
[quoted text clipped - 29 lines]
>
>Leon.
Ow, btw; when you want your cs-menu to work properly you should add a
variable EnableExpand or something and check on that before
e.Cancel=true, because it blocks everything... Spotting the blindingly
obvious here, but I thought I mention it anyway.
Leon.
BBM - 30 Nov 2004 13:33 GMT
Thanks Leon.
BBM
> >>I have a TreeView in which the nodes represent more complex objects. There
> >>are several levels of objects (Parent/Child/GrandChild/GreatGrandChild) with
[quoted text clipped - 36 lines]
>
> Leon.