如何在DataGridView中显示ComboBox?
大家好,我有两个名为brand(id,name)
和product(id,brandid,name)
的表格,我想在datagridview(id,名称,品牌)
,品牌列
应为combobox
,请参阅brandID
in in
表产品表
和显示品牌名称
来自brand
表的记录的名称
如何做到
品牌表
产品表
”
sstatic.net/9jq6u.png“ rel =“ nofollow noreferrer”> < href =“ https://i.sstatic.net/jbinh.png” rel =“ nofollow noreferrer”>
Hello everyone I have two Tables named Brand(Id,Name)
and Product(Id,BrandId,Name)
, I want showing Product list in DataGridView(Id,Name,Brand)
, Brand Column
should be ComboBox
that refer to BrandId
in Product Table
and shows Name Of Brand
from records in Brand
table
How can do it
Brand Table
Product Table
DataGridView
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以看到该列是我们的
combobox
使用与普通combobox相同的绑定系统。为此,我使用了该单元列出的列表来填充它,但是通常您会从数据库中加载数据。可以说,您拥有这样的品牌类别:
您从数据库加载数据并创建以下对象列表:
然后,您将将上层ComboBox列定义更改为:
You can see that column which is our
ComboBox
use same binding system as normal combobox. For this purposle I used list of tuples to populate it, but you would normally load data from database for that part.Lets say you have Brand class like this:
You load data from database and create list of these objects:
Then you would change upper combobox column definition to: