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 / .NET Framework / New Users / August 2004

Tip: Looking for answers? Try searching our database.

Treenode selection confusing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Aristeidis Bampakos - 15 Jul 2004 10:46 GMT
I have a tree node called Sales with two child nodes, Persons and Products. There are also two context menus, one for Sales and one for Persons/Products.When I select Sales with left click its ok. After I have selected Sales, I right-click a child node but the context menu of the Sales appears. That is the selection of the tree node remains to the previous one
Bharat Biyani - 02 Aug 2004 08:29 GMT
Hi,

You have not included the code to show what u are doing. However I guess you must be changing the context menu in the AfterSelect event of the treeview. However the selectednode property does not change when we right click on the node. So u will have to set the selectednode to the 1 which u have rightclicked in the mousedown event . Now the code in the AfterSelect event will work.
Here is a sample code listing:

private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
if(treeView1.SelectedNode.Text=="Sales")
   treeView1.ContextMenu=salesMenu;
else
   treeView1.ContextMenu=childMenu;
}

private void treeView1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(treeView1.GetNodeAt(e.X, e.Y)!=null)
{    treeView1.SelectedNode= treeView1.GetNodeAt(e.X, e.Y);
}
}

If u do not wish to change the SelectedNode on right click just move the code where u are assigning the context menu in AfterSelect to MouseDown event.
Signature

Bharat Biyani (bsb@orcim.com)
http://www.orcim.com

> I have a tree node called Sales with two child nodes, Persons and Products. There are also two context menus, one for Sales and one for Persons/Products.When I select Sales with left click its ok. After I have selected Sales, I right-click a child node but the context menu of the Sales appears. That is the selection of the tree node remains to the previous one

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.