ComboBox Problem

  • Thread starter Thread starter Lars Netzel
  • Start date Start date
L

Lars Netzel

I have a Combobox that is filled from a dataset.

I want to let the user be able to edit the text in the Combobox and if he
enters a text that is not a equal to any of the items in the combobox, I
want to catch that event.

As it is right now, the text the user wrote is overwritten with the
selecteditem when he leaves the Combobox.

Please help/
Lars
 
I added a combobox and set it's DropDownStyle to DropDown and then populate it using a Datatable in my Dataset. Using DropDown as the DropDownStyle allows you to enter text and what I typed in did not get replaced when I tabbed out of the combobox. I then used the Leave event of the combobox to check to see if what is in the text portion is in the datatable. Below for example

Private Sub ComboBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.Leav
If DataSet.Datatable.Select("ColumnName = '" + ComboBox1.Text + "'").Length = 0 The
'Item typed is not in datatabl
Els
'Item is in databl
End I
End Su

Hope this helps
 
okey! Yeah I did the same thing and it works.. my problem is that in the
place where it doesn't work it's because it's a DataGridComboBox and it
does, or does not other things that are affecting this. That Special Class
that is written to make it possible to add it in a datagrid doesn't keep the
written value, it takes the selected value and use CurrencyManager to put
back that on the row in the datagrid when leaving. The written value is all
gone then.

Don't really know what to do about this! Don't really understand that class

/Lars


gb said:
I added a combobox and set it's DropDownStyle to DropDown and then
populate it using a Datatable in my Dataset. Using DropDown as the
DropDownStyle allows you to enter text and what I typed in did not get
replaced when I tabbed out of the combobox. I then used the Leave event of
the combobox to check to see if what is in the text portion is in the
datatable. Below for example:
Private Sub ComboBox1_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ComboBox1.Leave
 
Back
Top