This is a migrated thread and some comments may be shown as answers.

Problem with "Enter" in Multiline GridViewTextBoxColumn

1 Answer 147 Views
GridView
This is a migrated thread and some comments may be shown as answers.
willi
Top achievements
Rank 1
willi asked on 25 Jun 2010, 09:05 AM
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 ObjectByVal 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 ObjectByVal 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 

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 30 Jun 2010, 01:59 PM
Hello willi,

It seems that the multiline TextBox looses focus when you click it while editing. You can focus it using the MouseClick click in the MyTextBoxEditorElement class:

Public Sub New()
    MyBase.New(New TextBox())
 
    ' ...
 
    DirectCast(Me.HostedControl, TextBox).MouseClick += New MouseEventHandler(AddressOf MyTextBoxEditorElement_MouseClick)
End Sub
 
Private Sub MyTextBoxEditorElement_MouseClick(sender As Object, e As MouseEventArgs)
    DirectCast(Me.HostedControl, TextBox).Focus()
End Sub


Regards,
Alexander
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
willi
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or