Press Enter key, then Combobox clear text, how to stop it ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • QuangNhat
    New Member
    • Apr 2012
    • 4

    Press Enter key, then Combobox clear text, how to stop it ?

    Hi,
    I use Combobox in DropDownStyle = simple, and AutoCompleteMod e, I bind DataSource for Combobox. So I have a Combobox AutoComplete with a list from Database.
    When I use in DropDownStyle = DropDownList, it don't have problem.
    But when I use it in Simple, when I chose a item by press Enter, Text of Combobox is cleared. I use PreviewKeyDown and set again text for Combobox. But there are 2 times occur this event, and text is set 1 times, then it is cleared.
    Please help me solve this problem. Thanks.
    I post 4 images. First image is I chose item.
    Second image is PreviewKeyDown occur first time.
    Third image is set Text of Combobox (it is cleared).
    Fourth image is PreviewKeyDown occur again, then Text is cleared.
    Attached Files
  • QuangNhat
    New Member
    • Apr 2012
    • 4

    #2
    :), I have just find the answer, I add a command, result:
    Code:
    if (e.KeyValue == 13)
                {
                    if (Combobox.Text != "")
                        StringGlobal = Combobox.Text;
                    if (Combobox.Text == "")
                        Combobox.Text = StringGlobal;
                }
    But I use mouse to chose the item, text is cleared.
    Last edited by Meetee; May 1 '12, 11:17 AM. Reason: code tags added

    Comment

    • RhysW
      New Member
      • Mar 2012
      • 70

      #3
      i would say you aren't using the autocomplete properly then if its deleting everything

      Comment

      • QuangNhat
        New Member
        • Apr 2012
        • 4

        #4
        I want to create a input (input commands) that it have a function like intellsense. I have found on internet and I found 2 ways: use rich textbox + custom code (harder) and autocomplete combobox.
        My combobox (more important properties):
        AutoCompleteMod e = SuggestAppend
        AutoCompleteSou rce = ListItems
        DropDownStyle = Simple
        DataSource = MyDataBindingSo urce
        My combobox display a list of commands. When user type, it show commands follow character is typed.
        If who can have a solution for my problem, I thank you.

        Comment

        Working...