|
Hello, I have a DataGridView.The RowTemplate.ContextMenuStrip is assigned. I want to programatically disable menustripitems. In the handler for the event Opening on the contextMenuStrip i have cms.Items[0].Enabled=false
But the menuitem is still enabled..it is clickable..Any idea why is this happening ?
| | emarinescu Tuesday, March 03, 2009 12:03 PM | Thanks for your reply..I allready resolved it by handling the RowContextMenuStripNeeded for the DataGridView..I assign there the ContextMenuStrip property of args parameter..here is the enabled/disabled logic.. Thanks anyway for responding - Marked As Answer byBruce.ZhouMSFT, ModeratorMonday, March 09, 2009 8:20 AM
- Proposed As Answer byJordan At Kawa Thursday, March 05, 2009 9:10 PM
-
| | emarinescu Thursday, March 05, 2009 12:46 PM | Hi, I'm just throwing my 2 cents in, hoping it will be helpfull. I had a similar requirement (only I'm changing visibility, not the Enabled property). The following code segment, should however work the same for either property. For me the key is to apply the settings in the "Opened" event, notthe "Opening" event. Let me know if it helps.
| 1 |
PrivateSubTransactionContextMenu_Opened(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesTransactionContextMenu.Opened |
| 2 |
'FilterorUnfilter |
| 3 |
If(Me.assetIdFilterIsNothing)Then |
| 4 |
Me.FilterByThisAssetToolStripMenuItem.Visible=True |
| 5 |
Me.RemoveAssetIdFilterToolStripMenuItem.Visible=False |
| 6 |
Else |
| 7 |
Me.FilterByThisAssetToolStripMenuItem.Visible=False |
| 8 |
Me.RemoveAssetIdFilterToolStripMenuItem.Visible=True |
| 9 |
EndIf |
| 10 |
EndSub | - Marked As Answer byBruce.ZhouMSFT, ModeratorMonday, March 09, 2009 8:20 AM
- Proposed As Answer byJordan At Kawa Thursday, March 05, 2009 9:10 PM
-
| | Jordan At Kawa Wednesday, March 04, 2009 12:28 AM | Hi, I'm just throwing my 2 cents in, hoping it will be helpfull. I had a similar requirement (only I'm changing visibility, not the Enabled property). The following code segment, should however work the same for either property. For me the key is to apply the settings in the "Opened" event, notthe "Opening" event. Let me know if it helps.
| 1 |
PrivateSubTransactionContextMenu_Opened(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesTransactionContextMenu.Opened |
| 2 |
'FilterorUnfilter |
| 3 |
If(Me.assetIdFilterIsNothing)Then |
| 4 |
Me.FilterByThisAssetToolStripMenuItem.Visible=True |
| 5 |
Me.RemoveAssetIdFilterToolStripMenuItem.Visible=False |
| 6 |
Else |
| 7 |
Me.FilterByThisAssetToolStripMenuItem.Visible=False |
| 8 |
Me.RemoveAssetIdFilterToolStripMenuItem.Visible=True |
| 9 |
EndIf |
| 10 |
EndSub | - Marked As Answer byBruce.ZhouMSFT, ModeratorMonday, March 09, 2009 8:20 AM
- Proposed As Answer byJordan At Kawa Thursday, March 05, 2009 9:10 PM
-
| | Jordan At Kawa Wednesday, March 04, 2009 12:28 AM | Thanks for your reply..I allready resolved it by handling the RowContextMenuStripNeeded for the DataGridView..I assign there the ContextMenuStrip property of args parameter..here is the enabled/disabled logic.. Thanks anyway for responding - Marked As Answer byBruce.ZhouMSFT, ModeratorMonday, March 09, 2009 8:20 AM
- Proposed As Answer byJordan At Kawa Thursday, March 05, 2009 9:10 PM
-
| | emarinescu Thursday, March 05, 2009 12:46 PM | i have the same trouble as yours,can you please tell me more details about how you solve this problem。�
some code will be best...thanks | | yeng25 Tuesday, September 29, 2009 6:10 AM |
|