Javier Salas
Javier Salas

Reputation: 1188

How to fill combobox with Datatable column C#

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?

Upvotes: 0

Views: 7530

Answers (1)

Mitrucho
Mitrucho

Reputation: 136

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"

Upvotes: 6

Related Questions