简体   繁体   English

如何根据从另一个组合框所做的选择填充组合框

[英]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.

相关问题 如何从另一个组合框填充相同形式的组合框? - How to populate a combo box from another combo box in the same form? C#Windows窗体如何根据第一个组合框中的选择更改第二个组合框的值 - C# Windows Forms how to change values of second combo box based on selection in first combo box 如何在当前组合框中选择值时显示另一个组合框? - How to make visible another combo box on selection of a value in current combo box? 根据C#中组合框选择中的字符串存储整数 - Store an integer based on a string from a combo box selection in C# 根据数据网格视图选择绑定到组合框 - Bind to Combo box based on Data Gridview selection 如何根据组合框选择更新datagridview? - How to update datagridview based off of combo box selection? C#从方法填充组合框 - C# populate a combo box from a method 如何通过从组合框中选择任何表来填充DataGridView - How to populate a DataGridView by selecting any table from combo box 组合框绑定到需要在组合框上进行选择之前显示全部的字段 - Combo box bound to a field required to show All before a selection is made on the Combo box 我有两个组合框和xml文件,我想从xml中填充组合框1中的服务器名称,并根据服务器名称填充第二个组合框 - i have two combo boxes and xml file, i want to populate server name in combo box 1 from xml and based on server name populate second combo box
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM