Questions tagged [contextmenustrip]

ContextMenuStrip should appear when a user right-clicks, reacting to the surroundings. It represents a shortcut menu in C#.

ContextMenuStrip replaces ContextMenu. You can associate a ContextMenuStrip with any control, and a right mouse click automatically displays the shortcut menu. You can show a ContextMenuStrip programmatically by using the Show method. ContextMenuStrip supports cancelable Opening and Closing events to handle dynamic population and multiple-click scenarios. ContextMenuStrip supports images, menu-item check state, text, access keys, shortcuts, and cascading menus.

For more details: http://msdn.microsoft.com/en-us/library/system.windows.forms.contextmenustrip(v=vs.110).aspx

293 questions
93
votes
6 answers

Determine what control the ContextMenuStrip was used on

I have a ContextMenuStrip that is assigned to several different listboxes. I am trying to figure out when the ContextMenuStrip is clicked what ListBox it was used on. I tried the code below as a start but it is not working. The sender has the…
Taryn
  • 242,637
  • 56
  • 362
  • 405
31
votes
2 answers

How to add sub menu items in contextmenustrip using C#4.0?

I have one contextmenustrip control associated with treenode. I have created one menu item in contextmenustrip manually in the form itself(for example named as "Assign"). Now I want to add sub menu items whenever user clicks this Assign item, it…
Saravanan
  • 11,372
  • 43
  • 143
  • 213
21
votes
10 answers

how to show contextmenustrip when a button is clicked in the right position

I want to click on a button and have it show a ContextMenuStrip right below the button. It keeps showing up in the left hand side of the screen when i try PointToScreen and top and left coordinates. Any suggestions?
leora
  • 188,729
  • 360
  • 878
  • 1,366
16
votes
9 answers

Do not close ContextMenuStrip on selection of certain items

Is it possible to leave a ContextMenuStrip open after a selection/check of certain items? I plan on using a simple ContextMenuStrip to set a filter (this way i could use the same filter either in a menu or as a right-click option). The menu lists a…
barry
  • 1,021
  • 3
  • 13
  • 27
13
votes
2 answers

Invoke ToolStripMenuItem

I'm trying to figure out if there's a way to Invoke ToolStripMenuItem. For example,I am calling a web service(ASynchrously) when result is returned.i populate drop down items according to result,(In call back method) …
Zain Ali
  • 15,535
  • 14
  • 95
  • 108
13
votes
1 answer

ContextMenuStrip.Owner Property null When Retrieving From Nested ToolStripMenuItem

I have a ContextMenuStrip setup with two ToolStripItems. The second ToolStripItem has two additional nested ToolStripItems. I define this as: ContextMenuStrip cms = new ContextMenuStrip(); ToolStripMenuItem contextJumpTo = new…
Michael Mankus
  • 4,628
  • 9
  • 37
  • 63
10
votes
2 answers

Different ContextMenuStrip for DataGridView Cell, RowHeader and ColumnHeader

I want to set different ContextMenuStrip for DataGridView Cells, RowHeaders and ColumnHeaders. The idea is that when I right-click any of these items, a different ContextMenuStrip is displayed. How do I do this?
Smith
  • 5,765
  • 17
  • 102
  • 161
10
votes
5 answers

How do you get the control that was clicked to open a ContextMenuStrip?

I'm using a ContextMenuStrip for multiple controls and I'm trying to figure out the best way to get the control that was actually clicked on to open the Context Menu. The sender just gives the ToolStripMenuItem reference, which has an Owner…
9
votes
2 answers

Can't set the position of a contextmenustrip?

I'm trying to open a contextmenustrip at the place where I right-clicked the mouse, but it always shows at top left of the screen. Here is the code I used: private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs…
Tarik Mokafih
  • 1,247
  • 7
  • 19
  • 38
9
votes
6 answers

Show checkbox for Context MenuStrip or Context Menu of a button

I am designing a logging feature in which User can select which event he wants to log. On clicking button, I am showing such type of menu: User can select multiple Events so I need to show "Check Mark" infront of the selected option when user…
Swanand
  • 4,027
  • 10
  • 41
  • 69
8
votes
2 answers

How to add a contextMenu programmatically in C#(VS 2008)?

I'm using VS 2008, and I would like to add a contextMenu (definitely not ContextMenuStrip!!) to my application. There is no contextMenu (!!) in the toolbox. So how can I add it programmatically to my code? Thanks In Advance,
SandhraPrakash
  • 442
  • 2
  • 6
  • 15
6
votes
2 answers

How to disable menu items in the ContextMenuStrip?

I have options like "Add", "Delete" and "Update" in my ContextMenuStrip, which should pop up when the user right clicks on a ListView. How can I make the Update menu disabled if there are no items in the list view?
Prasad MV
  • 107
  • 2
  • 3
  • 10
5
votes
0 answers

Source control is null when accessing from a sub context menu item in C#

I am trying to change the color of a button when they click on a sub menu item (colors > red) from a Context Menu Strip. This code is attached to user defined amount of buttons. To figure out which button they are trying to change, I am trying to go…
AustinWBryan
  • 3,249
  • 3
  • 24
  • 42
5
votes
1 answer

C# DataGridView Right Click to ContextMenu Click Retrieve Cell Value

I have a DataGridView. I have created a ContextMenuStrip when Right Clicking a Cell in column 4 of my DataGridView. I am however stuck because on left clicking the ContextMenuStrip Menu Item I would like the extract the data from the cell that was…
Matt
  • 358
  • 3
  • 9
  • 23
4
votes
2 answers

C# - Context Menu Strip has scroll behaviour when user hits arrow keys

I have a context menu strip with 8 items and two separators. When the user brings up the context menu strip, then hits the arrow key to scroll through the items, hitting the eighth item causes the menu to 'scroll' up, leaving blank space at the…
genki
  • 301
  • 2
  • 11
1
2 3
19 20