Gold
Gold

Reputation: 62554

how to bind table from database to checkedListBox?

i have this table MEN: id,Fname and i have checkeddListBox

i bind like this:

this.ListAtar.DataSource = dsView.Tables[0];

this.ListAtar.DisplayMember = dsView.Tables[0].Columns[0].ColumnName; //Fname

this.ListAtar.ValueMember = dsView.Tables[0].Columns[1].ColumnName; //ID

but if i pick some items, how i can see the list of the ID that i pick ?

thank's in advance

Upvotes: 0

Views: 5097

Answers (2)

Austin Salonen
Austin Salonen

Reputation: 50245

You'll want to set the CheckedListBox.DisplayMember to Fname and the CheckedListBox.ValueMember to id.


myCheckedListBox.DisplayMember = "Fname";
myCheckedListBox.ValueMember = "id";

For what it's worth, it's easier to set these values in the Designer.

Upvotes: 2

Fredou
Fredou

Reputation: 20140

you bind the datasource then set the DisplayMember and ValueMember properties then call the DataBind method

like a when you play around with dropdownlist, combox, listbox, etc...

Upvotes: 0

Related Questions