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

Multi Column in C#

$
0
0

Hy, I have a problem

I have this code to show the multi column in combobox, the problem is I wanna put the name into combobox when I clicked and I wanna put code into another column, Does anyone could help me, this is my code

private void IsiComboDiagnosa1()
        {
            System.Data.SqlClient.SqlConnection conn = konn.GetConn();
            try
            {
                SqlCommand cmd = new SqlCommand("Select Code, Diagnosa from RefDiagnosa", conn);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    comboBox3.Items.Add(ds.Tables[0].Rows[i][0] + " " + ds.Tables[0].Rows[i][1]); 
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

thanks for your help

Best Regards,

Steve Henry


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>