如何将数据表附加到datagridview的组合框列 [英] how to attach a datatable to combobox column of datagridview
问题描述
你好,
我正在使用datagridview,在datagridview中,我有一个产品名称的组合框列.我有一个包含productname和productid的数据表.
我正在尝试将此数据表作为productname as display member
和productid as valuemember
的数据源附加到组合框列上
我正在尝试在组合框中键入内容,当我键入内容时,我会尝试根据键入的字母显示一个列表.
该怎么做?
请帮助
Hello,
I am using datagridview, in datagridview I have a combobox column for product name. I have A datatable containing productname and productid.
I am trying to attach this datatable to combobox column as datasource with productname as display member
and productid as valuemember
also
I am trying to type in combobox and when I type I try to display a list according to alphabet typed.
How to do this?
Please help
推荐答案
你好亚丁,
我无法完全理解您的问题,
但只要试试这个
将ComboBox属性设置为
Hello Yatin,
i Can''t understood your problem completely,
but just try this
Set ComboBox Properties as
ComboBox.DropdownStyle = DropDownList;
ComboBox.Sorted = true
;
Yatin,
试试这个链接:
http://homepage.ntlworld.com/herring1/datagrid.html [
Hi Yatin,
Try this link :
http://homepage.ntlworld.com/herring1/datagrid.html[^]
Hope to be helpful
:)
请注意,datatable
,productid
和productname
只是重新表达,它们在您自己中应该是有意义的代码.
please note thatdatatable
,productid
andproductname
are only represnetations and they need to be meanigful code in your part.
ComboBox.DataSource = datatable
ComboBox.DataValueField = productid
ComboBox.DataTextField = productname
请参阅ComboBox文档 http://msdn.microsoft.com/en-us/library /system.windows.forms.combobox.aspx [
See ComboBox Documentation http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.aspx[^]
这篇关于如何将数据表附加到datagridview的组合框列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!