JaedenRuiner
Well-known member
- Joined
- Aug 13, 2007
- Messages
- 340
- Programming Experience
- 10+
Well,
This one is annoying. Given this setup:
Let us assume that the binding source is set to a datatable, and the variables (components) are all built with the designer so they handle events and everything ( i just didn't feel like typeing all the params and such)
When the user selects via the arrow keys or mouse an item in the list the TextChanged, SelectedValue, and SelectedIndex events all fire in that order. (I've stepped it to be sure)
However, since the DataSource is set on the combobox AND the combobox style is DropDown i'm noticing a little problem with the currently selected value/item/index etc. The BindingSource and ComboBox Index just stay put, they don't shift when the user types in the combobox. Now a static list in the Items would normally cause the SelectedIndex to revert to -1, or at least it used to in other languages (Delphi, VB6, VBA), so how can I tell the system:
"OKay This item the user is typing is Not in the List, so blank all other bound fields, and wait for the user to exit the control."
When they exit the control continue with
"The User has exited is and the item is still not in the list, so prepare to add a new item to the datasource."
Frankily it seems a bit limited that they no longer have teh "Item Not In List" event like what existed in VB6/A, which was so helpful in trapping when a item was typed in that is not on the item list. and When using a BindingSource/DataTable as the DataSource for the List, the ComboBox.Items are DataRowViews, not Strings (or whatever value the ValueMember column would be), so I can't even do, ComboBox.Items.IndexOf(X) = -1.
Any suggestions?
This one is annoying. Given this setup:
VB.NET:
private cmb as ComboBox
private bind as bindingsource
public sub Form_Shown() handles me.shown
cmb.datasource = bind
cmb.AutoCompleteMode = Append
cmb.AutoCompleteSource = ListItems
cmb.DropDownStyle = DropDown
cmb.displaymember = "col1"
cmb.valuemember = "col2"
end sub
public sub cmb_SelectedValue() handles cmb.selectedValue
end sub
public sub TextChanged() handles cmb.TextChanged
end sub
Let us assume that the binding source is set to a datatable, and the variables (components) are all built with the designer so they handle events and everything ( i just didn't feel like typeing all the params and such)
When the user selects via the arrow keys or mouse an item in the list the TextChanged, SelectedValue, and SelectedIndex events all fire in that order. (I've stepped it to be sure)
However, since the DataSource is set on the combobox AND the combobox style is DropDown i'm noticing a little problem with the currently selected value/item/index etc. The BindingSource and ComboBox Index just stay put, they don't shift when the user types in the combobox. Now a static list in the Items would normally cause the SelectedIndex to revert to -1, or at least it used to in other languages (Delphi, VB6, VBA), so how can I tell the system:
"OKay This item the user is typing is Not in the List, so blank all other bound fields, and wait for the user to exit the control."
When they exit the control continue with
"The User has exited is and the item is still not in the list, so prepare to add a new item to the datasource."
Frankily it seems a bit limited that they no longer have teh "Item Not In List" event like what existed in VB6/A, which was so helpful in trapping when a item was typed in that is not on the item list. and When using a BindingSource/DataTable as the DataSource for the List, the ComboBox.Items are DataRowViews, not Strings (or whatever value the ValueMember column would be), so I can't even do, ComboBox.Items.IndexOf(X) = -1.
Any suggestions?