How to put two columns in a combo box
-
tPlease help. How to put two columns in a combo box. I work with VS2015, c # and mjskl 5.7. Attached part of the code. private void comboBox1_Click (object sender, EventArgs e) { MySqlConnection conn; myConnectionString = pwput; conn = new MySql.Data.MySqlClient.MySqlConnection (); conn.ConnectionString = myConnectionString; try { conn.Open (); } catch (MySqlException ex) { switch (ex.Number) { case 0: MessageBox.Show ("DO NOT SUCCE TO CONNECT ON SERVER, CLOSE PROGRAM TO TAKE A REPLY"); Close (); break; case 1042: MessageBox.Show ("NOT ACTIVE SERVER, SUBSCRIBE SERVER PA REPEAT CONNECTING"); Close (); break; } conn.Close (); } if (conn.State! = ConnectionState.Open) { MessageBox.Show ("DO NOT SUCCE TO CONNECT ON SERVER \ r \ n CLOSE PROGRAM TO TAKE READY \ r \ n"); } else { AutoCompleteStringCollection kontoopis = new AutoCompleteStringCollection (); string wnadidok = "SELECT idkonto, FROM account name"; loadingData = false; DataTable dtkon = new DataTable (); dtkon.Columns.Add (); dtkon.Columns.Add (); MySqlDataAdapter mdkon = new MySqlDataAdapter (wnadidok, conn); mdkon.Fill (dtkon); loadingData = true; comboBox1.DataSource = dtkon; // which field is shown in the table below comboBox1.DisplayMember = "idkonto"; comboBox1.ValueMember = "idkonto"; comboBox1.DisplayMember = "title"; comboBox1.ValueMember = "title"; comboBox1.SelectedIndex = -1; comboBox1.Text = ""; loadingData = false; } conn.Close (); } Thank you
-
tPlease help. How to put two columns in a combo box. I work with VS2015, c # and mjskl 5.7. Attached part of the code. private void comboBox1_Click (object sender, EventArgs e) { MySqlConnection conn; myConnectionString = pwput; conn = new MySql.Data.MySqlClient.MySqlConnection (); conn.ConnectionString = myConnectionString; try { conn.Open (); } catch (MySqlException ex) { switch (ex.Number) { case 0: MessageBox.Show ("DO NOT SUCCE TO CONNECT ON SERVER, CLOSE PROGRAM TO TAKE A REPLY"); Close (); break; case 1042: MessageBox.Show ("NOT ACTIVE SERVER, SUBSCRIBE SERVER PA REPEAT CONNECTING"); Close (); break; } conn.Close (); } if (conn.State! = ConnectionState.Open) { MessageBox.Show ("DO NOT SUCCE TO CONNECT ON SERVER \ r \ n CLOSE PROGRAM TO TAKE READY \ r \ n"); } else { AutoCompleteStringCollection kontoopis = new AutoCompleteStringCollection (); string wnadidok = "SELECT idkonto, FROM account name"; loadingData = false; DataTable dtkon = new DataTable (); dtkon.Columns.Add (); dtkon.Columns.Add (); MySqlDataAdapter mdkon = new MySqlDataAdapter (wnadidok, conn); mdkon.Fill (dtkon); loadingData = true; comboBox1.DataSource = dtkon; // which field is shown in the table below comboBox1.DisplayMember = "idkonto"; comboBox1.ValueMember = "idkonto"; comboBox1.DisplayMember = "title"; comboBox1.ValueMember = "title"; comboBox1.SelectedIndex = -1; comboBox1.Text = ""; loadingData = false; } conn.Close (); } Thank you
Please don't post questions to multiple forums. You have already asked this at How to put two columns in a combo box - C# Discussion Boards[^] and this forum is for general Visual Studio / .NET 4.6 topics but not for language specific questions.