[英]How to populate a combo box based on the selection made from another combo box
Hie, am using visual studio 2010 C#. 嗨,我正在使用Visual Studio 2010 C#。 i would like to populate my vehicle model combo box based on the vehicle make selected on the top combo box eg if someone select a honda for the make, the second combo box should only populate honda models thus crv, legend, hrv etc. i have also created a 2008 SQL server database that contains two tables, 1 for vehicle makes and the other 1 for model.
我想根据在顶部组合框中选择的车辆制造商来填充我的车辆模型组合箱,例如,如果有人选择本田作为制造商,则第二个组合箱应仅填充本田模型,因此,crv,legend,hrv等。还创建了一个2008 SQL Server数据库,其中包含两个表,一个用于车辆制造商,另一个用于模型。 thanx
谢谢
You'll have to hook up the change event on your main combobox, and then filter or set the source of the other comboboxes depending on that selection 您必须在主组合框上连接change事件,然后根据该选择过滤或设置其他组合框的源
You could do that with properties, collections, hardcode, linq, and so on, but since you don't have any code, it's a bit hard to point you in a better direction. 您可以使用属性,集合,硬代码,linq等来完成此操作,但是由于您没有任何代码,因此很难为您指明更好的方向。
if (ComboVehicleMake.SelectedValue != null && Convert.ToInt32(ComboVehicleMake.SelectedValue) == 27)
{
try
{
.......// bind the other combobox
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.