Overrides RadTextBoxControlEditor theme

1 Answer 23 Views
GridView
Henri
Top achievements
Rank 2
Iron
Iron
Iron
Henri asked on 04 Oct 2024, 06:01 AM

Hi, anyone can help me with the issue below?

I have a customized theme applied in my application. However, a customized editor doesn't apply the theme. I am not able to override the theme here.

    Private Sub RadGridView3_EditorRequired(sender As Object, e As EditorRequiredEventArgs) Handles RadGridView3.EditorRequired
        If RadGridView3.CurrentColumn.HeaderText = "Section" Then
            e.Editor = New MyAutoCompleteEditor
        End If
    End Sub

 

Class MyAutoCompleteEditor
    Inherits RadTextBoxControlEditor

    Protected Overrides Function CreateEditorElement() As Telerik.WinControls.RadElement
        Dim element As New RadAutoCompleteBoxElement With {
            .AutoCompleteMode = AutoCompleteMode.Suggest
        }

        Return element
    End Function

    Public Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
        Dim element As RadAutoCompleteBoxElement = TryCast(Me.EditorElement, RadAutoCompleteBoxElement)

        If element.TextLength >= 40 Then
            e.SuppressKeyPress = True
        End If

        RemoveHandler element.KeyPress, AddressOf RadAutoCompleteBox_KeyPress
        AddHandler element.KeyPress, AddressOf RadAutoCompleteBox_KeyPress
        RemoveHandler element.TextChanging, AddressOf RadAutoCompleteBox_TextChanging
        AddHandler element.TextChanging, AddressOf RadAutoCompleteBox_TextChanging

        If element.IsAutoCompleteDropDownOpen Then
            Return
        End If

        MyBase.OnKeyDown(e)
    End Sub

    Private Sub RadAutoCompleteBox_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
        Dim element As RadAutoCompleteBoxElement = TryCast(sender, RadAutoCompleteBoxElement)

        If element.Items.Count > 0 Then
            e.Handled = True
        End If

    End Sub

    Private Sub RadAutoCompleteBox_TextChanging(ByVal sender As Object, ByVal e As Telerik.WinControls.TextChangingEventArgs)
        If e.NewValue = "" Then
            Return
        End If

        Dim el As RadAutoCompleteBoxElement = TryCast(sender, RadAutoCompleteBoxElement)

        If el.Items.Count > 0 Then
            e.Cancel = True
        End If
    End Sub

End Class

Text column


In the custom column, control is running on the Visual Studio 2022 theme.

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 08 Oct 2024, 10:53 AM

Hello, Henri,

According to the provided code snippet, it seems that you use a custom RadTextBoxControlEditor with RadAutoCompleteBoxElement. I can not be sure why your custom is not applied to the editor, but what I can suggest is to set ShouldApplyTheme=true. Can you give this suggestion a try and let me know how it goes. 

In case you are having further difficulties applying the theme, I would kindly ask you to isolate this problem in a sample runnable project and replicate the problem there together with the customized theme. Thus, I could be able to investigate more precisely what exactly is happening and determine whether the problem comes from the theme itself or the way it is applied to the control's hierarchy. Also, can you please confirm if your custom theme is correctly applied to other controls and forms? 

I am looking forward to your reply.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GridView
Asked by
Henri
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or