Hi!
Im trying to use an alternative GridEditor to input Enter into an Textfield in an RadGridView and found the example above anywhere here in the forum.
The problem is, when I'm clicking in the Editbox to edit the text everything works fine, but when I click on the same or on an other textfield in the grid no cursor is shown and it's not possible to edit the fields as long as i reopen the form.
Please help
regards
Willi
Use:
Private Sub grdOPdaten2_EditorRequired(ByVal sender As Object, ByVal e As EditorRequiredEventArgs) Handles grdOPdaten2.EditorRequired |
If e.EditorType Is GetType(RadTextBoxEditor) Then |
e.EditorType = GetType(MyTextBoxEditor) |
End If |
End Sub |
Class:
Public Class MyTextBoxEditor |
Inherits BaseGridEditor |
Public Overrides Property Value() As Object |
Get |
Dim editorElement As MyTextBoxEditorElement = DirectCast(Me.EditorElement, MyTextBoxEditorElement) |
Return editorElement.HostedControl.Text |
End Get |
Set(ByVal value As Object) |
Dim editorElement As MyTextBoxEditorElement = DirectCast(Me.EditorElement, MyTextBoxEditorElement) |
If value Is Nothing OrElse value Is DBNull.Value Then |
editorElement.HostedControl.Text = String.Empty |
Else |
editorElement.HostedControl.Text = value.ToString() |
End If |
End Set |
End Property |
Public Overrides Sub BeginEdit() |
MyBase.BeginEdit() |
Dim editorElement As MyTextBoxEditorElement = DirectCast(Me.EditorElement, MyTextBoxEditorElement) |
editorElement.HostedControl.BackColor = Color.White |
End Sub |
Protected Overrides Function CreateEditorElement() As RadElement |
Return New MyTextBoxEditorElement() |
End Function |
End Class |
Public Class MyTextBoxEditorElement |
Inherits RadHostItem |
Public Sub New() |
MyBase.New(New TextBox()) |
Me.StretchHorizontally = True |
Me.StretchVertically = True |
DirectCast(Me.HostedControl, TextBox).AcceptsReturn = True |
DirectCast(Me.HostedControl, TextBox).AcceptsTab = True |
DirectCast(Me.HostedControl, TextBox).Multiline = True |
AddHandler DirectCast(Me.HostedControl, TextBox).KeyDown, AddressOf MyTextBoxEditorElement_KeyDown |
End Sub |
Private Sub MyTextBoxEditorElement_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) |
If e.KeyCode = Keys.Escape OrElse _ |
(e.KeyCode = Keys.Enter AndAlso e.Modifiers = Keys.Shift) OrElse _ |
e.KeyCode = Keys.Tab Then |
Dim grid As RadGridView = DirectCast(Me.ElementTree.Control, RadGridView) |
grid.GridBehavior.ProcessKeyDown(New KeyEventArgs(e.KeyCode)) |
End If |
End Sub |
End Class |