Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Context menu sub menu appears on the top of the screen
 

Context menu sub menu appears on the top of the screen

Hello,

I have a problem with one of my context menus. I have a form and on the form we display a Drawing consistign of several items that can be selected.

When a particular item is selected and then right clicked the context menu comes up. There is no probel till here.
But when I try to navigate to a child menu of a item in context menu, the new sub menu positions on top left most of the screen.

I am really tired of debugging and checking the propeties of it. Any help please.

Thanks in advacne.

Regards,
Gopi
Krishna
Krishna Kal  Thursday, August 27, 2009 5:15 PM
menu.ShowDropDown();

instead, you could use

menu.DropDown.Show(GiveLocationHere);


Thanks

â™?My Blog â™?My Flickr â™?My Facebook â™?/div>
  • Marked As Answer byKrishna Kal Thursday, August 27, 2009 7:02 PM
  •  
Omie  Thursday, August 27, 2009 6:51 PM
Is that context menu/sub menu created at runtime ? If yes, post code please.


Thanks

â™?My Blog â™?My Flickr â™?My Facebook â™?/div>
Omie  Thursday, August 27, 2009 6:29 PM
Yes, Its being added at run time. Below is the code

List<object> result = e.Result as List<object>;
ToolStripDropDownItem menu = result[0] as ToolStripDropDownItem;
List<FormCategory> formCategories = result[1] as List<FormCategory>;
int count = menu.DropDownItems.Count;
ToolStripMenuItem tempItem = new ToolStripMenuItem("Getting Form Results...");
menu.DropDownItems.Clear();
if (menu != null)
{
ToolStripMenuItem newCategory = null;
foreach (FormCategory cat in formCategories)
{
newCategory = new ToolStripMenuItem(cat.Name);
newCategory.Tag = cat;
newCategory.DropDownOpening += newCategory_DropDownOpening;
newCategory.DropDownItems.Add(tempItem);
menu.DropDownItems.Add(newCategory); 
//menu.DropDownItems.Add(tempItem);
//tempItem.DropDownItems.Add(newCategory);
}
menu.ShowDropDown();
}

Thanks,
Gopi


Krishna
Krishna Kal  Thursday, August 27, 2009 6:42 PM
menu.ShowDropDown();

instead, you could use

menu.DropDown.Show(GiveLocationHere);


Thanks

â™?My Blog â™?My Flickr â™?My Facebook â™?/div>
  • Marked As Answer byKrishna Kal Thursday, August 27, 2009 7:02 PM
  •  
Omie  Thursday, August 27, 2009 6:51 PM

You can use google to search for other answers

Custom Search

More Threads

• How can I bind a toolbar to a form and unbind it to another form (like vs.net)
• how to avoid multiple task icons in the taskbar.
• Change label text when dropping on hosted designer
• Appbars
• Radio button column in winforms datagrid
• How to Add UserControl as TreeNode
• How to assign string resource to user control's property at design time?
• How to write codes to changes the sound volume
• How to change the width of the tool tip.
• Component's Event double-click error in Property Window