开发者

Columns Order In Datagridview With ComboBox

What is the correct way of datagridviewcomboboxcolumn bind with sql database and re- arrange with other column. Suppose if I have columns like below.

  1. Srno

  2. Particulars // this columns is for datagridviewcomboBoxColumn

  3. Amount.

I wants the datagridview’s columns correct order as above and the same is for the purpose

of data entry.

Suppose开发者_JS百科 if I have Following Dummy Table like

dummy

  1. Srno

  2. Particulars

  3. 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.

  1. Datagridview.columns[0] is for srno

  2. Datagridview.columns[1] is for Particulars

  3. Datagridview.columns[2] is for Amount

Note:- "I need the correct way to add all three columns in datagridview as above order"


Set the DisplayIndex properties of the columns.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜