What is the correct way of datagridviewcomboboxcolumn bind with sql database and re- arrange with other column. Suppose if I have columns like below.
Srno
Particulars // this columns is for datagridviewcomboBoxColumn
Amount.
I wants the datagridview's columns correct order as above and the same is for the purpose
of data entry.
Suppose if I have Following Dummy Table like
dummy
Srno
Particulars
Amount.
MySqlConnection Code is as below.
string cons = "server=.;initial catalog=maa;uid=mah;pwd=mah";
SqlConnection con = new SqlConnection(cons); con.Open(); string sql = "select particulars from dummy"; SqlDataAdapter dap = new SqlDataAdapter(sql, con); DataSet ds = new DataSet(); dap.Fill(ds); DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn(); cmb.DataSource = ds.Tables[0]; cmb.DisplayMember = "name"; cmb.ValueMember = "name"; dataGridView1.Columns.Add(cmb);
|
The above datagridviewcomboboxcolumn is set to dgv.columns[0] where as I wants the dgv
columns orders as below.
Datagridview.columns[0] is for srno
Datagridview.columns[1] is for Particulars //For datagridviewcomboBoxColumn.
Datagridview.columns[2] is for Amount
Note:- "I need the correct way to add all three columns in datagridview as above order"