private void productlist_Load(object sender, EventArgs e) { con.Open(); SqlCommand cmd = new SqlCommand("select productcode,productname from products", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { listBox1.Items.Add(ds.Tables[0].Rows[i][0].ToString() + "\t\t" + ds.Tables[0].Rows[i][1].ToString()); } con.Close(); }
ListBox.SelectItem
textBx1.Text = ListBox1.SelectedItem.Value;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)