开发者

how to bind table from database to checkedListBox?

开发者 https://www.devze.com 2022-12-21 02:26 出处:网络
i have this table MEN: id,Fname and i have checkeddListBox i bind like this: this.ListAtar.DataSource = dsView.Tables[0];

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.Table开发者_开发百科s[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...

0

精彩评论

暂无评论...
验证码 换一张
取 消