Databound combobox problem (mouse vs. keyboard)

J

JohnRou

I'm having a really weird problem with a combo box (drop down list) on
a databound form.

I load 3 values programmatically into the combo box "MALE" "FEMALE"
and "UNKNOWN". When I run the app, if I tab to the combo box and type
'm' on the keyboard "MALE" shows up in the combo box, but it doesn't
save when I execute my .update statement. But, if I click on the list
and select "MALE" from the drop down list, it saves into the database
just fine.

The only thing I can think of is that the Selected_Index_Changed event
fires for either the keyboard or the mouse, but the Text_Changed event
only fires with the mouse... I don't even know if that makes a
difference.

What I'd like is for the user to be able to type "m" and have the
value save.... how can I do that??

Using vb 2005 and SQL Server 2005

Thank you,

John
 
N

neeraj

I'm having a really weird problem with a combo box (drop down list) on
a databound form.

I load 3 values programmatically into the combo box "MALE" "FEMALE"
and "UNKNOWN".  When I run the app, if I tab to the combo box and type
'm' on the keyboard "MALE" shows up in the combo box, but it doesn't
save when I execute my .update statement.  But, if I click on the list
and select "MALE" from the drop down list, it saves into the database
just fine.

The only thing I can think of is that the Selected_Index_Changed event
fires for either the keyboard or the mouse, but the Text_Changed event
only fires with the mouse... I don't even know if that makes a
difference.

What I'd like is for the user to be able to type "m" and have the
value save.... how can I do that??

Using vb 2005 and SQL Server 2005

Thank you,

John

Are you talking about Web application or Windows application ?
 
J

JohnRou

please give me code hows you doing ?

no code really.....

The Form_Load:
1) loads the combo box with the values
2) Fills the table adapter

The Form_Unload
1) Calls the binding source .EndEdit()
2) Calls the table adapter .Update() command

The bindings were setup through the IDE.

I don't think the problem is the code because there really isn't
anything to speak of as it relates to the combo box. All of the other
fields save correctly (textbox, checkbox, etc.) The combo box even
saves correctly as long as you pick the item from the pull down. It
just won't save if you select it with the keyboard.

I don't have any combo box code at all except the windows generated
code:
Me.cboSex.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.bsGlobal_Person, "Sex", True))
Me.cboSex.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboSex.FormattingEnabled = True
Me.cboSex.Location = New System.Drawing.Point(66, 104)
Me.cboSex.Name = "cboSex"
Me.cboSex.Size = New System.Drawing.Size(99, 25)
Me.cboSex.TabIndex = 3
 
N

neeraj

no code really.....

The Form_Load:
1) loads the combo box with the values
2) Fills the table adapter

The Form_Unload
1) Calls the binding source .EndEdit()
2) Calls the table adapter .Update() command

The bindings were setup through the IDE.

I don't think the problem is the code because there really isn't
anything to speak of as it relates to the combo box.  All of the other
fields save correctly (textbox, checkbox, etc.) The combo box even
saves correctly as long as you pick the item from the pull down.  It
just won't save if you select it with the keyboard.

I don't have any combo box code at all except the windows generated
code:
        Me.cboSex.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.bsGlobal_Person, "Sex", True))
        Me.cboSex.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cboSex.FormattingEnabled = True
        Me.cboSex.Location = New System.Drawing.Point(66, 104)
        Me.cboSex.Name = "cboSex"
        Me.cboSex.Size = New System.Drawing.Size(99, 25)
        Me.cboSex.TabIndex = 3

make one another simple form and do just again . May be you have
missed somhing in you settings ..
 
J

JohnRou

make one another simple form and do just again . May be you have
missed somhing in you settings ..- Hide quoted text -

I had tried that earlier with the same result. I even created a new
SQL database with just two fields to test it... same result. On my
real form, I have a bunch of comboboxes and they all function the same
way. It's not intermittant and only bothers the combo boxes....
 
J

JohnRou

With a lot of help, the problem has been identified. It turns out
that the VB IDE binds comboboxes to the Text property. That is
causing the erratic behavior. If you change the bind to the
SelectedItem value it works fine......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top