如何用数据表列C#填充组合框 [英] How to fill combobox with Datatable column C#

查看:58
本文介绍了如何用数据表列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?

推荐答案

我认为您需要使用Display和Value成员属性来处理显示数据.

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"

这篇关于如何用数据表列C#填充组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆