combobox text

  • Thread starter Thread starter Richard Bond
  • Start date Start date
R

Richard Bond

Hi,

I have a combobox that is bound to a list of text and values in a dataset.
It is in Dropdown mode - which enables the user to type in their own text if
they so wish. when I process the form, I check the Selected value property,
if it is 0 (not one of my bound values) then I know to add their new item to
my database using the combobox.Text property (after prompting them with a
few questions) .

I want to programatically set the text of the combobox with a suggested
value not in the bound list, like so:

myComboBox.Text = "NewText"

but when I check the Text property of the combobox I get the first value in
the bound dataset - even though I can see the text has been correctly set in
the form.(unlike when the user manually types in some new text).

Is there something else I can do?

regards,

Rich
 
You can add the text/record to the datasource the ComboBox is bound to then
make sure to handle the extra row in your code as to not push it back when
updating the database.

For example, if your ComboBox is bound to a DataTable add the row before
filling it and it will show up as the first record in the ComboBox.

Steve Stein
VB Team
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top