Hi
I want to hide the system context menu which is visible when cell is in edit mode and user presses right button. I come to know that it can be disable on EditingControlShowing event of DataGridView. But as this event is not available in RadGridView, How can I disable or hide this context menu. Any help would be appreciated!
Regards!
4 Answers, 1 is accepted
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 11 Jan 2011, 03:31 PM
Hello Michael,
In order to do this, you could create a custom cell for the editor. Here is a very basic example
and then handle the EditorRequired event
for more information on Custom Cells, please take a look at this documentation
hope that helps
Richard
In order to do this, you could create a custom cell for the editor. Here is a very basic example
Public Class TextEditor Inherits BaseGridEditor Private radTextBox As RadTextBox Public Sub New() radTextBox = New RadTextBox() radTextBox.TextBoxElement.TextBoxItem.HostedControl.ContextMenu = New ContextMenu() radTextBox.TextBoxElement.TextBoxItem.SelectionStart = 0 End Sub Private Sub radTextBox_TextChanged(ByVal sender As Object, ByVal e As EventArgs) OnValueChanged() End Sub Protected Overrides Function CreateEditorElement() As RadElement Return New RadHostItem(radTextBox) End Function Public Overrides Property Value() As Object Get Return radTextBox.Text End Get Set(ByVal value As Object) radTextBox.Text = value.ToString() End Set End PropertyEnd Class Public Class MyTextEditorElement Inherits RadTextBoxElement Public Sub New() Me.CanFocus = True End Sub Protected Overrides ReadOnly Property ThemeEffectiveType() As Type Get Return GetType(RadTextBoxElement) End Get End Property Protected Overrides Sub OnPropertyChanged(ByVal e As RadPropertyChangedEventArgs) MyBase.OnPropertyChanged(e) End SubEnd Classand then handle the EditorRequired event
Private Sub RadGridView1_EditorRequired(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.EditorRequiredEventArgs) Handles RadGridView1.EditorRequired If e.EditorType Is GetType(RadTextBoxEditor) Then e.EditorType = GetType(TextEditor) End IfEnd Subfor more information on Custom Cells, please take a look at this documentation
hope that helps
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 12 Jan 2011, 04:09 PM
Hello,
Did this help? If so please remember to mark as answer. If you need more assistance, please let me know.
Thanks
Richard
Did this help? If so please remember to mark as answer. If you need more assistance, please let me know.
Thanks
Richard
0
Zerka
Top achievements
Rank 1
answered on 09 Mar 2011, 10:51 AM
Hello Richard
Sorry, I had been busy with some other high priority tasks. Yes It works. But in this way, I will lose some other features of RadTextBox. Also I have differnet kind of columns in my grid and hence different editors, so this requires a lot of code just for hiding this default system context menu.
Thanks
Regards
Sorry, I had been busy with some other high priority tasks. Yes It works. But in this way, I will lose some other features of RadTextBox. Also I have differnet kind of columns in my grid and hence different editors, so this requires a lot of code just for hiding this default system context menu.
Thanks
Regards
0
Hi Michael,
I just would like to suggest another idea to remove the default context menu, which could match your scenario better. You can do that by accessing the TextBox item in the standard RadTextBoxEditor. Please consider the following code as example:
I hope this helps. Let me know if you have any additional questions.
Best wishes,
Martin Vasilev
the Telerik team
I just would like to suggest another idea to remove the default context menu, which could match your scenario better. You can do that by accessing the TextBox item in the standard RadTextBoxEditor. Please consider the following code as example:
void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) { RadTextBoxEditor editor = e.ActiveEditor as RadTextBoxEditor; if (editor != null) { RadTextBoxEditorElement editorElement = (RadTextBoxEditorElement)editor.EditorElement; (editorElement.HostedControl as TextBox).ContextMenu = new ContextMenu(); } }I hope this helps. Let me know if you have any additional questions.
Best wishes,
Martin Vasilev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!