Click to See Complete Forum and Search --> : Context Menu
bismitapadhi
October 7th, 2009, 01:38 AM
I have just added contextmenu from the toolbar added its sub item. I build the solution and run it.Nut on right click it is not showing the context menu. Anything else i need to do to show the context menu on right click in the editor. I am a very beginner to C Sharp.please help me.
lion.king
October 7th, 2009, 01:59 AM
did u added menu items to that context menu. other wise u wont see anything after right click .
bismitapadhi
October 7th, 2009, 02:47 AM
did u added menu items to that context menu. other wise u wont see anything after right click .i have already added menu item,but i am unable to see.
dannystommen
October 7th, 2009, 03:06 AM
You need to show the contextmenu yourself
Code example of showing a contextmenu when the mouse is clicked on a listview
private void listview1_MouseClick(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Right) {
contextMenu1.Show(listview1, new Point(e.X, e.Y));
}
}
lion.king
October 7th, 2009, 03:11 AM
You need to show the contextmenu yourself
Code example of showing a contextmenu when the mouse is clicked on a listview
private void listview1_MouseClick(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Right) {
contextMenu1.Show(listview1, new Point(e.X, e.Y));
}
}
i am sure in c# or any .net no need of this code. if u added contextmenu to any item, it will be shown on right click.it wont show even when u add it is when u did not add any menu item to that context menu.
dannystommen
October 7th, 2009, 03:17 AM
i am sure in c# or any .net no need of this code. if u added contextmenu to any item, it will be shown on right click.it wont show even when u add it is when u did not add any menu item to that context menu.
You are absolutely right! Missed that property till now..
Any way, to test it, I created a ContextMenuStrip, and set a buttons ContextMenuStrip property to this menustrip. It worked fine.
@bismitapadhi: Did you set this ContextMenuStrip property of the control where you want to show the context menu?
bismitapadhi
October 7th, 2009, 03:25 AM
You are absolutely right! Missed that property till now..
Any way, to test it, I created a ContextMenuStrip, and set a buttons ContextMenuStrip property to this menustrip. It worked fine.
@bismitapadhi: Did you set this ContextMenuStrip property of the control where you want to show the context menu?i haven't seted any control,in properties where i need to set the control.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.