Designing my own Combobox

Hi, i'm developing my own control inherited from combobox class, but i have some problems with the dropdown, keydown behaviours. More exactly, when i press enter button in the smarthphone and a combobox have focus i don't want to shown all combobox items list to select one. I have made my own combo, something like this :

Public Class Class1
Inherits System.Windows.Forms.ComboBox

Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
If (e.KeyCode = System.Windows.Forms.Keys.Enter) Then
MsgBox("hi")
Else
MsgBox("bye")
MyBase.OnKeyDown(e)
End If
End Sub

Public Sub New()
Me.Items.Add("Baseball")
Me.Items.Add("futbol")
Me.Items.Add("soccer")
Me.Items.Add("basketball")
End Sub
End Class

But, it isn't work correctly, i have supposed this component, after push enter key, will show the "hi" message and after this NOTHING, but, not .. when I press enter key .. my class show me the "hi" message and after this .. show me the combobox item list .. and theoretically, if i override a event in a inherited class .. why this works I must to declare a delegate, any ideas Please help me!!



Answer this question

Designing my own Combobox

  • gauls

    Hello ..
    I found the solution ..

    Public Class Class1
    Inherits System.Windows.Forms.ComboBox

    Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
    If (e.KeyCode = System.Windows.Forms.Keys.Enter) Then
    MsgBox("capullo")
    e.Handled = True
    Else
    MsgBox("gili")
    End If
    End Sub

    Public Sub New()
    Me.Items.Add("Baseball")
    Me.Items.Add("futbol")
    Me.Items.Add("soccer")
    Me.Items.Add("basketball")
    End Sub
    End Class

    I'm sorry but i haven't try this .. with this e.Handled = true the default delegate don't catch the event after my code ..

  • Designing my own Combobox