By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,716 Members | 1,304 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,716 IT Pros & Developers. It's quick & easy.

ComboBox Problem

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
gb
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
Nov 20 '05 #2

P: n/a
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" <an*******@discussions.microsoft.com> skrev i meddelandet
news:AC**********************************@microsof t.com...
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 If DataSet.Datatable.Select("ColumnName = '" + ComboBox1.Text + "'").Length = 0 Then 'Item typed is not in datatable
Else
'Item is in datable
End If
End Sub
Hope this helps

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.