Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / November 2004

Tip: Looking for answers? Try searching our database.

Double-click behavior of TreeView - changeable?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BBM - 29 Nov 2004 20:31 GMT
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
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 - 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.