Hi,
when i right click in a cell in the grid view, i get the standard popup menu that allows to copy, paste etc.
how can i add to this menu another custom button without creating a new context menu ?
Thanks ,
Hi,
when i right click in a cell in the grid view, i get the standard popup menu that allows to copy, paste etc.
how can i add to this menu another custom button without creating a new context menu ?
Thanks ,
Hi,
To accomplish this task, handle the GridView.ShownEditor event to get an active in-place editor.
he editor's context menu is created once before it is shown. Thus, it was null in your case. To determine the moment when the context menu is shown, handle the RepositoryItemTextEdit.BeforeShowMenu event to add a custom menu item.
Visual BasicPrivate Sub gridView2_ShownEditor(ByVal sender As Object, ByVal e As EventArgs)
Dim textBox As TextEdit = TryCast(gridView2.ActiveEditor, TextEdit)
AddHandler textBox.Properties.BeforeShowMenu, AddressOf Properties_BeforeShowMenu
End Sub
Private Sub Properties_BeforeShowMenu(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.BeforeShowMenuEventArgs)
Dim menu As DevExpress.Utils.Menu.DXPopupMenu = e.Menu
menu.Items.Add(New DXMenuItem("My item"))
End Sub
This code is applicable for all the TextEdit class descendants.
Please refer to the How to force a grid to show my own context menu instead of the standard one when right-clicking an in-place editor article for more information.
I have created a sample based on your description. Please find it in the attachment.
I hope this information will be helpful to you. Feel free to contact us if you have further difficulties. We are happy to help you at any time.
Thanks for the reply,
i tested it but i got a Null reference Exeption 'Object reference not set to an instance of an object.' i looked and found that the activeEditor.ContextMenu = Nothing.
please advise what i can do without havong to build my own context menu. i want to use the default popup menu.
Thanks,
I have reviewed my answer and think that it was not complete enough. Please accept my apologies. The editor's context menu is created once before it is shown. Thus, it was null in your case. To determine the moment when the context menu is shown, handle the RepositoryItemTextEdit.BeforeShowMenu event to add a custom menu item.
Visual BasicPrivate Sub gridView2_ShownEditor(ByVal sender As Object, ByVal e As EventArgs)
Dim textBox As TextEdit = TryCast(gridView2.ActiveEditor, TextEdit)
AddHandler textBox.Properties.BeforeShowMenu, AddressOf Properties_BeforeShowMenu
End Sub
Private Sub Properties_BeforeShowMenu(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.BeforeShowMenuEventArgs)
Dim menu As DevExpress.Utils.Menu.DXPopupMenu = e.Menu
menu.Items.Add(New DXMenuItem("My item"))
End Sub
This code is applicable for all the TextEdit class descendants.
I have created a sample based on your description. Please find it in the attachment.
I have updated my previous answer accordingly.
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.