Re: TreeView: right-click
Peter Osucha <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <00e501c7912b$579bfb90$0202a8c0@peterhome> |
Check that... Put two controls on a form. One being a tree view - add some nodes. The other being something else like a listbox. IN the mousedown event for the treeview, set the SelectedNode using treeview1.SelectedNode = treeview1.GetNodeAt(e.X, e.Y). Run the app. Right click on the list box. Right click on the treeview but in an empty area of the treeview. Note that although the SelectedNode is null, the first item in the tree is highlighted. Any way to stop this? Peter -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Peter Osucha Sent: Monday, May 07, 2007 4:08 PM To: [email protected] Subject: Re: [DOTNET-WINFORMS] TreeView: right-click Thanks, Patrick. Works like a charm. -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Patrick Steele Sent: Sunday, May 06, 2007 9:52 PM To: [email protected] Subject: Re: [DOTNET-WINFORMS] TreeView: right-click TreeView.GetNodeAt(x,y) --- Patrick Steele http://weblogs.asp.net/psteele -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Peter Osucha Sent: Sunday, May 06, 2007 9:38 PM To: [email protected] Subject: Re: [DOTNET-WINFORMS] TreeView: right-click Patrick, First, it must be in the mousedown event. What is available for finding the clicked node in this event? Nothing else has happened to the tree yet when this event fires. I do have access to the x, y, and location variables form the MouseEventArgs argument. How do you find the clicked node from these? Peter -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Patrick Steele Sent: Sunday, May 06, 2007 7:42 AM To: [email protected] Subject: Re: [DOTNET-WINFORMS] TreeView: right-click In the MouseDown (or maybe MouseUp) event, if the right-mouse was clicked, set the SelectedNode property to the Node that was clicked on. --- Patrick Steele http://weblogs.asp.net/psteele -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Peter Osucha Sent: Sunday, May 06, 2007 1:34 AM To: [email protected] Subject: [DOTNET-WINFORMS] TreeView: right-click And since it's late and my brain isn't working well right now, one more... I have a TreeView control on a form with a bunch of nodes displayed. If I 'left-click', the treeview highlight shows on the item I clicked. However, if I 'right-click', it doesn't. How do I change the TreeView's behavior so that the 'right-click' moves the highlight just like the 'left-click' does (the same behavior that happends in Windows Explorer), please? Peter