简体   繁体   中英

How to populate a combo box based on the selection made from another combo box

该表格添加了具有唯一参考编号的新查询

Hie, am using 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. 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

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.

  if (ComboVehicleMake.SelectedValue != null && Convert.ToInt32(ComboVehicleMake.SelectedValue) == 27)
    {
        try
        {
        .......// bind the other combobox

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM