Jim,
You need to use a ContextMenu on your Form. In the ContextMenu Popup event, code something like this:
private void oContextMenu_Popup(object sender, System.EventArgs e)
{
this.oContextMenu.MenuItems.Clear();
MenuItem oItem;
switch (this.oTree.SelectedID)
{
case "First Tree Item" :
oItem = new MenuItem("First Stuff To Do");
oItem.Click += new System.EventHandler(this.oMenu_Handler);
this.oContextMenu.MenuItems.Add(oItem);
oItem = new MenuItem("More First Stuff To Do");
oItem.Click += new System.EventHandler(this.oMenu_Handler);
this.oContextMenu.MenuItems.Add(oItem);
break;
case "Second Tree Item" :
oItem = new MenuItem("Second Stuff To Do");
oItem.Click += new System.EventHandler(this.oMenu_Handler);
this.oContextMenu.MenuItems.Add(oItem);
oItem = new MenuItem("More Second Stuff To Do");
oItem.Click += new System.EventHandler(this.oMenu_Handler);
this.oContextMenu.MenuItems.Add(oItem);
break;
}
}
private void oMenu_Handler(object sender, System.EventArgs e)
{
MenuItem item = (MenuItem)sender;
switch (item.Text)
{
case "First Stuff To Do" :
break;
}
}
HTH,
~~Bonnie
>All,
>
> I have an application with a treeview control. I want to be able to rightclick and display a menu. The options in the menu will be determined by the type of item that is clicked on. What is the best way to go about this?