本文介绍了链接两个组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,
我有两个Windows形式的组合框,一个用于省份,第二个用于区域.我需要的是,当某人选择一个项目(省)时,所有相关的项目(区)都应出现在第二个组合框中,我已经在DBMS中使用表格完成了此操作,但是我想直接使用c#进行操作,有什么主意吗?请帮帮我!

Dear All,
I''ve two combo boxes in windows form, One is for Province and the second one is for district. All i need is when someone selects an item (Province)all relevant Items (Districts) should come in second combobox, I''ve done it using table in DBMS but i want to do it directly with c#, any idea? Please help me!

推荐答案


var selectedDistricts = from district in Districts where district.ProvinceID == selectedProvince.ID select district;



另一种选择是具有一个在数据库中查找并返回具有所选省份ID的所有地区的函数.即
"



The other option is to have a function which looks up in the database and returns all districts with the selected provinces id.i.e

"SELECT id, name, provinceID, etc FROM Districts WHERE provinceID = @provinceID;" 

,其中provincenid是选定的省份ID.

where provinceid is the selected provinces id.


这篇关于链接两个组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 03:33