Winforms combobox loses autocomplete value on lostfocus

六眼飞鱼酱① 提交于 2019-11-29 14:34:28

I have found this link from microsoft

http://connect.microsoft.com/VisualStudio/feedback/details/711945/tab-on-a-winforms-combobox-with-properties-autocompletemode-append-autocompletesource-listitems-doesnt-work-correctly

Basically this is a known issue that microsoft say they will not fix. However there are two workarounds under the workarounds section of that link.

The value gets lost at the WM_KILLFOCUS message. Overriding WndProc in a subclass of ComboBox solved this issue for me (except for the clicking to loose focus... but I guess this could be explained as dismissing like on a dialog of a website). Unfortunately, I have only VB.NET-code at hand:

Protected Overrides Sub WndProc(ByRef m As Message)
    If m.Msg = &H8 Then  'WM_KILLFOCUS
        Dim sText As String = Me.Text
        MyBase.WndProc(m)
        Me.Text = sText
        Exit Sub
    End If

    MyBase.WndProc(m)
End Sub
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!