How to fill combobox with Datatable column C#

Deadly 提交于 2021-02-05 11:22:51

问题


I'm trying to add items to a combo box using a data table that already has some columns but I just want one of them values into the combo box. What i'm doing is this:

cbReviewers.DataSource = Reviewers_table.Columns[1];

but is not working, do you know how could I do it?


回答1:


I think you need to use Display and Value members properties to work with display data.

cbReviewers.DataSource = Reviewers_table
cbReviewers.DisplayMember = "ColumnNameThatContainsText"
cbReviewers.ValueMember = "ColumnNameThatContainsValue"


来源:https://stackoverflow.com/questions/46082802/how-to-fill-combobox-with-datatable-column-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!