Problem with Combobox and SelectedValue

Hi again from Spain.
I'm working with the beta2 (VB.NET) and i have a problem with a ComboBox and the SelectedValue propertie.
I fill a Combo from a database and i use the AutoComplete feature to make easy select a value.
But... if i use TAB to enter the Combo... i type the value or select it with the keyboard... and ... then use the TAB to go to the next control (or click with the mouse in other field, button, etc)... the SELECTEDVALUE of this combo is NULL.
In the combo appear the text of the value... but i need to select it with the mouse or press ENTER to assing the value to the SELECTEDVALUE propertie of the Combo.
Sorry if my english is not very good... :(
Any solution?
A very BIG thanks! :)

[746 byte] By [Fametown.com] at [2007-12-16]
# 1
If you set AutoCompleteMode to Append and AutoCompleteSource to ListItems then you could tab through your combobox.

Marinus

Marinus at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
Hi,

try to make use of:

LostFocusControl
Occurs when the control loses focus.

and

FindString Finds the first item in the T:System.Windows.Forms.ComboBox that starts with the specified string.
FindStringExact Finds the item that exactly matches the specified string.

rgerbig at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

Hi,
You need to add this line;

combobox1.SelectedValue = combobox1.Text

in the aprpriate events. I think most apropriate would be valuechanged

Good luck Smile

Fayed at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4
I set the AutoCompleteMode to Append and the source to ListItems... and don't work. :(
It's a bug in Beta2?
Fametown.com at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 5
I just created a new project in Beta2. Dropped a Combobox, filled in some items. set AutoCompleteMode to Append and the source to ListItems. Added som textboxes to enable tabbing. And it just works fine. So there is some other option that you are setting and I don't.
Marinus
Marinus at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 6
Hi,

I think the value changed event is not fired, because the selectedvalue should be set then to the right value, isn't it ?Tongue Tied

rgerbig at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 7

rgidbig

could be... I have not tried it before... but since he is using autocomplete, it can be trigered either by valuechanged or keypress

Fayed at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 8
Thanks for the replays.
I use this code in the "Leave" event. I don't find "LostFocusControl " in the ComboBox.
Now works fine... thanks... but... i think this is a bug... ! :)

Dim index As Integer
index = MyComboBox.FindString(MyComboBoxComboBox.Text)
MyComboBoxComboBox.SelectedIndex = index

Fametown.com at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 9
Hi,

I took that event of ComboBox from the online MSDN. I think you found an mistake in it, too Big Smile

rgerbig at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 10
Hi,
let's first learn what is combobox. this is consider with using textbox, button and listbox right.
lostfocus event is not a bug, but it is not handle easily so programer face some kind of problems.
you have some knoledage about Overriding. This concept will solve your problem if your will foucs lost with using Tab key but if you focus lost with using mouse click than parallarly you have to handles a mouse click event for all componet except combo.
about both combination will 100% solve you problems.
1)protected overrides processcmdkey(.....)
in body of the methods you will handle Tab and Enter key event and pick value from combobox to any variable as well as you want.
end sub
2)private sub control_MouseClick(byval sender as object, byval e as system.eventargs) _
handles a1.mouseclick, b1.mouseclick, c1.mouseclick, etc
in body of the routine you will handle Tab and Enter key event and pick value from combobox to any variable as well as you want.
end sub
sender Rajat Solanki, (rajatsolanki@yahoo.com)
RajatSolanki at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...