Hi,
I am using Janus MultiCheckBoxList and cannot get it to work with Csla.
Below is some sample code of how it would work with a dataset, I just cannot get it to work with BindingSource control, my problem is with the relationship between the BindingSource data controls.
Please can someone point me in the right direction.
Public Class Form1
Private dataSet As DataSet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CreateDummyData()
BindCategoriesCombo()
End Sub
Private Sub CreateDummyData()
'Creating a DataSet with two tables: Contacts and Categories
'with a many-to-many relation
'using the auxiliary table Contacts-Categories
dataSet = New DataSet()
'Create table: "Contacts"
Dim contacts As New DataTable("Contacts")
contacts.Columns.Add("ContactId", GetType(Integer))
contacts.Columns.Add("Name", GetType(String))
contacts.Columns.Add("Phone", GetType(String))
contacts.PrimaryKey = New DataColumn() {contacts.Columns("ContactId")}
'Create table: "Categories"
Dim categories As New DataTable("Categories")
categories.Columns.Add("CategoryId", GetType(Integer))
categories.Columns.Add("CategoryName", GetType(String))
categories.PrimaryKey = New DataColumn() {categories.Columns("CategoryId")}
'Create intermediate table "ContactCategories"
Dim contactCategories As New DataTable("ContactCategories")
contactCategories.Columns.Add("ContactId", GetType(Integer))
contactCategories.Columns.Add("CategoryId", GetType(Integer))
contactCategories.PrimaryKey = New DataColumn() {contactCategories.Columns("ContactId"), contactCategories.Columns("CategoryId")}
dataSet.Tables.Add(contacts)
dataSet.Tables.Add(categories)
dataSet.Tables.Add(contactCategories)
'Define relations between tables
dataSet.Relations.Add("Contacts_ContactCategories", contacts.Columns("ContactId"), contactCategories.Columns("ContactId"))
dataSet.Relations.Add("Categories_ContactCategories", categories.Columns("CategoryId"), contactCategories.Columns("CategoryId"))
'Adding sample data
contacts.Rows.Add(1, "Paul Wagner", "(466) 123-5532")
contacts.Rows.Add(2, "Stephanie Welles", "(423) 324-9836")
contacts.Rows.Add(3, "James Jones", "(432) 566-8814")
categories.Rows.Add(1, "Family")
categories.Rows.Add(2, "Business")
categories.Rows.Add(3, "Personal")
categories.Rows.Add(4, "VIP")
categories.Rows.Add(5, "Customers")
categories.Rows.Add(6, "Suppliers")
'Paul Wagner belongs to categories 2, 4 and 5
contactCategories.Rows.Add(1, 2)
contactCategories.Rows.Add(1, 4)
contactCategories.Rows.Add(1, 5)
'Stephanie Welles belongs to category 1
contactCategories.Rows.Add(2, 1)
'James Jones Belongs to categories 2 and 6
contactCategories.Rows.Add(3, 2)
contactCategories.Rows.Add(3, 6)
End Sub
Private Sub BindCategoriesCombo()
'Set the datasource of the dropdown
Me.editCategories.DropDownDataSource = dataSet.Tables("Categories")
Me.editCategories.DropDownValueMember = "CategoryId"
Me.editCategories.DropDownDisplayMember = "CategoryName"
'Call RetrieveStructure to create the columns:
Me.editCategories.RetrieveStructure()
'Set the datasource of the list of values that appear checked in the dropdown
Me.editCategories.ValuesDataSource = dataSet
'DataMember must be equal to the name of the parent dataTable plus the name of the relation
Me.editCategories.ValuesDataMember = "Contacts.Contacts_ContactCategories"
'Now, define which field in the list of values will be used as value
Me.editCategories.ValueItemDataMember = "CategoryID"
End Sub
Thank you for your suggestion, however I have read the eBooks and all the other books.
I haven't had any problems with databinding before, my grids, text boxes and a multitude of other controls bind correctly, I just cannot get get it to work with this Janus Muli Select Check Box.
Your are correct in the book paying for itself though :-)
Thanks
Copyright (c) Marimer LLC