Browse by Tags
All Tags » ContextMenu » Using Controls (RSS)
Sorry, but there are no more tags available to filter with.
-
|
You can listen to the Popup event, determine where the mouse was clicked and selectively make the menu items visible in the menu as follows: private void contextMenu1_Popup( object sender, EventArgs e ) { // Get current mouse click position in the control...
|
-
|
The ContextMenu.SourceControl property will specify the latest Control on which the context menu was shown. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
The frame will manage a context menu for you if you set the control's ContextMenu property. Here is some code adding a context menu to a Label. //Add Menus in your form's constructor... this.pictureContextMenu = new ContextMenu(); this.pictureContextMenu...
|
-
|
Override WndProc in your Control and do the following. You should then listen to keyup and show the context menu yourself. [C#] private int const WM_CONTEXTMENU = 0x7b; private int const WM_KEYUP = 0x101; protected override void WndProc(ref Message m...
|
-
|
First keep track of which control is showing the ContextMenu by listening to the menu's Popup event and querying for the SourceControl. Then when you are ready to cancel the popup, do as follows: [DllImport("user32.dll", CharSet=CharSet...
|
-
|
Normally, the context menu will be shown at the center of the control when the keyboard is used to invoke the context menu of a control (Shift+F10, for example). You can customize the location as follows. Override WndProc in the grid and check if the...
|
-
|
To prevent the default context menu of a TextBox from showing up, assign a empty context menu as shown below: textBox1.ContextMenu = new ContextMenu(); Contributed from George Shepherd's Windows Forms FAQ
|
-
|
To automatically close the context menu after a set time interval, you can use a Timer and send an Esc keystroke after the desired time interval as shown: [C#] private void timer1_Tick(object sender, System.EventArgs e) { SendKeys.Send("{ESC}"...
|