Jyoti Jodha

Jyoti Jodha

  • NA
  • 1.7k
  • 406.3k

How to display two different columns in one combobox c#

Sep 21 2017 7:37 AM
How to display two different columns in one combobox windows form c#
DataRow dr;
con.Open();
SqlCommand cmd = new SqlCommand("select Product_ID,Name,Bar_Code from Product", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
dr = dt.NewRow();
dr.ItemArray = new object[] { 0, "--Select Product--" };
dt.Rows.InsertAt(dr, 0);
comboBoxproduct.ValueMember = "Product_ID";
comboBoxproduct.DisplayMember = "Name" or "Bar_Code";
comboBoxproduct.DataSource = dt;
con.Close();

Answers (10)