简体   繁体   中英

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

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.

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM