Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Creating a combo Box with mulitple colums

$
0
0
 

The code below lists my customers and displays the customer name allowing me to pick which I need. There are many customers with the same name so I have a branch field to uniquely identify . I would like my combo box to list customer Name | Branch. Also including the CUstomerRef (Which is the unique ID code). Is this possible???

var CustList = from qCust in context.tblCustomers
                           where qCust.CustomerName.Contains("")
                           select qCust;

            var singleCust = CustList.ToList();

            singleCust.Add(new tblCustomer() { CustomerName = "-- Please Select --", CustomerRef = -1 });

            comboCustomerName.DataSource = singleCust.OrderBy(c => c.CustomerName).ToList(); ;

            comboCustomerName.DisplayMember = "CustomerName";
            comboCustomerName.ValueMember = "CustomerRef";

                        

Viewing all articles
Browse latest Browse all 2535

Trending Articles