kpgraci
Active member
Hi all (again),
I have a class, clsCustomer, that implements INotifyPropertyChanged.
I bind its properties to textboxes on a form like this:
I have several comboboxes and I load their lists from a databse, no problem, like this:
I want to bind the 'selecteditem' of the combobox, so I'm guessing it would be similar to the textbox syntax,
but I'm not sure what property I'm actually binding here.
My goal is a two-way binding between the object property and the selected item in the combobox.
RESOLVED:
Assuming SelevtedValue (in my case, the id) is what's stored in the database, this works:
I have a class, clsCustomer, that implements INotifyPropertyChanged.
I bind its properties to textboxes on a form like this:
VB.NET:
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]
ClientNameTextBox.DataBindings.Add("Text", _client, "Name", True, DataSourceUpdateMode.OnPropertyChanged)
[/SIZE][/FONT][/SIZE][/FONT]
I have several comboboxes and I load their lists from a databse, no problem, like this:
VB.NET:
Dim cnn As New OleDbConnection(dbConnect)
Dim strSQL As String = "SELECT Display, [Value] FROM ClientNo"
Dim da As New OleDbDataAdapter(strSQL, cnn)
Dim ds As New DataSet
da.Fill(ds, "table")
With MyComboBox
.DataSource = ds.Tables("table")
.DisplayMember = "Display"
.ValueMember = "Value"
.SelectedIndex = -1
End With
cnn.Close()
I want to bind the 'selecteditem' of the combobox, so I'm guessing it would be similar to the textbox syntax,
but I'm not sure what property I'm actually binding here.
My goal is a two-way binding between the object property and the selected item in the combobox.
RESOLVED:
Assuming SelevtedValue (in my case, the id) is what's stored in the database, this works:
VB.NET:
[FONT=Consolas][SIZE=2]ClientNoComboBox.DataBindings.Add("SelectedValue", _client, "ClientNo", True, DataSourceUpdateMode.OnPropertyChanged)[/SIZE][/FONT]
Last edited: