DataGridView与Combobox过滤其他Combobox(级联组合框) [英] DataGridView with Combobox Filtering Other Combobox (cascading comboboxes)

查看:69
本文介绍了DataGridView与Combobox过滤其他Combobox(级联组合框)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用datagridview控件将costomer数据保存或更新到TblCustomer表中。



Datagridview中的ComboCountry必须过滤Combocity如果selectedindexchanges

两个组合必须具有id值和显示值。



我找到了一些关于级联组合框的代码,但无法做到。



任何人都可以给我看正确的代码。



谢谢。



我也不知道哪种方式更好地添加新记录:



1.添加10个empyt行,填充它们并按保存按钮

2. at datagridview的新行结束,填写新客户并按下键然后自动将数据保存到表格。(对不起我的英语不好)



TblCustomer表有4列

CustomerId为int

CustomerName为nvarchar

CountryId为int

CityId as int



数据示例:

1,Custo mer A,1,10

2,客户B,2,15



TblCountry表:

CountryId为int

国家为nvarchar



数据示例:

1,美国

2,TURKEY



TblCity表:

CityId为int

CountryId为int

City as nvarchar



数据示例:

10,1,Kansas

15,2,Istanbul

I want to use datagridview control to save or update costomer data into TblCustomer table.

ComboCountry in Datagridview must filter Combocity if selectedindexchanges
both combos must have id value and display value.

I found some codes about cascading comboboxes but couldnt do it.

Can anyone show me the correct code.

Thanks.

I also dont know which way is better to add new records:

1. add 10 empyt rows, fill them and press save button
2. at the end of the datagridview's new line, fill new customer and press down key then automatically saves the data to table.(sorry for my poor English)

TblCustomer Table has 4 columns
CustomerId as int
CustomerName as nvarchar
CountryId as int
CityId as int

data example:
1, "Customer A", 1, 10
2, "Customer B", 2, 15

TblCountry Table:
CountryId as int
Country as nvarchar

data example:
1, "USA"
2, "TURKEY"

TblCity Table:
CityId as int
CountryId as int
City as nvarchar

data example:
10, 1, "Kansas"
15, 2, "Istanbul"

推荐答案

参考 - 在C-Sharp.Net中层叠组合框 [ ^ ]。



关于更新,如果你可以立即更新它会很好。如果你用down键一个接一个地做,那就更复杂了,数据库上的负载会更多。
Refer - Cascading ComboBox in C-Sharp.Net[^].

And about the update, if you can update at once it would be good. If you do one by one with down key, it would be more complex and the load on database would be more.


你好,



参考:

1) Asp.net Gridview中的级联下拉列表示例

2)级联组合框


这篇关于DataGridView与Combobox过滤其他Combobox(级联组合框)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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