I am using Visual basic 2008 Express Edition.
I have a listbox on a form that is displaying records from a table called Categories. Next to that list box I have a CheckedListBox. When a use selects a category in the listbox, I want the CheckedListBox to be populated with data from the Groceries table, it should display all "Items" where the Category equals the value of the selected listbox selection.
Below is my attempt to accomplish this, however I seem to be missing the mark here.
Below is the error I get when I try to run the code.
Connections to my database are provided by BindingSource1, DatabaseDataSet1, CategoriesBindingSource and CategoriesTableAdapter.
Once I get the list to populate properly I will need to be able to populate another datagrid on the same form with items that are selected in the list.
So My form will look like this
Can anyone assist in identifying what I am doing wrong to populate my Checked List Box? Thanks,
Mark
I have a listbox on a form that is displaying records from a table called Categories. Next to that list box I have a CheckedListBox. When a use selects a category in the listbox, I want the CheckedListBox to be populated with data from the Groceries table, it should display all "Items" where the Category equals the value of the selected listbox selection.
Below is my attempt to accomplish this, however I seem to be missing the mark here.
Code:
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim db As New Database1DataSet
Dim Item As String
Dim SelectList = From Groceries In db.Groceries _
Where Groceries.Category = ListBox1.SelectedItem.ToString _
Select Groceries
Me.CheckedListBox1.DataSource = SelectList
End Sub
Below is the error I get when I try to run the code.
Complex DataBinding accepts as a data source either an IList or an IListSource.
Connections to my database are provided by BindingSource1, DatabaseDataSet1, CategoriesBindingSource and CategoriesTableAdapter.
Once I get the list to populate properly I will need to be able to populate another datagrid on the same form with items that are selected in the list.
So My form will look like this
Code:
____________ _____________________________________
|categories | | Checked List Box (items to select) |
|listbox | | |
|___________1| |____________________________________2|
_____________________________________________________
| Selected Items |
| |
|____________________________________________________3|
Can anyone assist in identifying what I am doing wrong to populate my Checked List Box? Thanks,
Mark