Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Autocomplete not firing events for combobox
 

Autocomplete not firing events for combobox

Hello, I have a very simple form that displays and allows users to edit vendor account information. I have a combo box from which the user can select a saved vendor and it will display that vendor. Works great. The problem is that I want the combo box to autocomplete just as I have always known combo boxes to do, but using automcomplete won't fire useful events for me.

I am using the autocomplete mode SuggestAppend (or Append)in VS2008 and it works fine as long as you use the mouse to select a vendor. If you type and accept the autocomplete suggestion,you can select a vendor, butthe SelectedChangeCommitted event won't fire, even if you tab out of the combo box. I tried testing the text property but it keeps firing when the form is loading.

Does anyone know how to make a combo box act like a long-time Windows user expects? It should allow you to select from the list, or type in values, with an autocomplete option that does not hinder the functionality provided by selecting the item from the drop-down.

Thanks,

Jason

Raleigh, North Carolina, USA

carlosthedonkey  Tuesday, June 10, 2008 6:16 PM

Oops. I'm sorry, I was thinking of a different bug.

For the standalone ComboBox,here ismy workaround. I've also talked with supportand they said the ComboBox will be fixed in a future release. I wish they would post a public bug database so I wouldn't have to waste timesolving bugs that have already been found.

Please note,it's been a long time since I worked with this.This might not be exactly the answer to the bug you found but itcould be ahelpful starting point.

Best Regards,

Aaron Stewart

Brigham Young University computer science student

* * *

Protected Shared Sub comboBox_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs)

' There is a glitch if you are using a ComboBox either in a DataGridView or standalone.

' If you open the ComboBox dropdown but then type a value and press ENTER, the value is lost.

' This error does not appear if you press TAB.

' This is the workaround.

If (e.KeyCode = Keys.Enter) Then

Dim cbo As ComboBox = sender

If cbo.DroppedDown Then

cbo.DroppedDown = False

End If

End If

' Allow the ESC key to cancel changes even if AutoComplete mode has been active.

If (e.KeyCode = Keys.Escape) Then

Dim cbo As ComboBox = sender

' I don't know why this works, but it does:

cbo.Text = ""

End If

End Sub

Aaron S_  Saturday, June 14, 2008 3:40 AM

Jason,

If you want behavior like Access or Excel, you might check into a third-party product... I think it's called SyncFusion Essential Grid. It costs a bundle but it might work for your needs. (I have never purchased it but last I checked they had a free demo).

If you want to use the DataGridView... it's broken. You areright that it does notfire events correctly with editable combo boxes. The functionality was never properly designed into it.

Aaron

Aaron S_  Saturday, June 14, 2008 1:02 AM

Oops. I'm sorry, I was thinking of a different bug.

For the standalone ComboBox,here ismy workaround. I've also talked with supportand they said the ComboBox will be fixed in a future release. I wish they would post a public bug database so I wouldn't have to waste timesolving bugs that have already been found.

Please note,it's been a long time since I worked with this.This might not be exactly the answer to the bug you found but itcould be ahelpful starting point.

Best Regards,

Aaron Stewart

Brigham Young University computer science student

* * *

Protected Shared Sub comboBox_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs)

' There is a glitch if you are using a ComboBox either in a DataGridView or standalone.

' If you open the ComboBox dropdown but then type a value and press ENTER, the value is lost.

' This error does not appear if you press TAB.

' This is the workaround.

If (e.KeyCode = Keys.Enter) Then

Dim cbo As ComboBox = sender

If cbo.DroppedDown Then

cbo.DroppedDown = False

End If

End If

' Allow the ESC key to cancel changes even if AutoComplete mode has been active.

If (e.KeyCode = Keys.Escape) Then

Dim cbo As ComboBox = sender

' I don't know why this works, but it does:

cbo.Text = ""

End If

End Sub

Aaron S_  Saturday, June 14, 2008 3:40 AM

You can use google to search for other answers

Custom Search

More Threads

• Creating a buddy Icon Class
• Can't view Form in Designer
• Property grid control type and control pattern
• convert word to pdf
• New WinForms FAQ repository created
• How to use pics in Controls
• UserControl custom property and UndoEngine
• Problem with code serialization for child controls
• manual position of Form2 from Form1
• Notify property changed in Smart Tag DesignerActionMethodItem