c# dataGridView cell添加下拉框

应用场景:

  dataGridView需要某一个cell变成下拉框样式。

思路详解:

  dataGridVie添加固定格式的row。

代码:

                    DataGridViewRow row = new DataGridViewRow();
                    row.Cells.Add(new DataGridViewTextBoxCell());
                    DataGridViewComboBoxCell comboxcell = new DataGridViewComboBoxCell();
                    
                    comboxcell.Items.Add("九");
                    comboxcell.Items.Add("平");
                    comboxcell.Items.Add("气");
                    comboxcell.Items.Add("阴");
                    comboxcell.Items.Add("阳");
                    comboxcell.Items.Add("痰");
                    comboxcell.Items.Add("气");
                    comboxcell.Items.Add("血");
                    comboxcell.Items.Add("特");
                    comboxcell.Items.Add("湿");
                    row.Cells.Add(comboxcell);
                    row.Cells.Add(new DataGridViewTextBoxCell());
                    row.Cells.Add(new DataGridViewTextBoxCell());
                    row.Cells.Add(new DataGridViewTextBoxCell());
                    dataGridView_pinggu.Rows.Add(row);

 难点:

  1.注意dataGridView属性readOnly,设成false。要不然下拉框不显示。

猜你喜欢

转载自www.cnblogs.com/gaara-zhang/p/10631153.html
今日推荐