我现在有个DataGridView,有两列,第一列为属性,第二列为属性值,现在问题是DataGridView的columnType属性要么全设置成combox那种样式,要么全是textbox样式,我向根据属性的不同每行的输入格式也不同,还请各位高手指教??

解决方案 »

  1.   

    编辑列不是有columnType这个属性嘛,直接改啊
      

  2.   

    数据行一旦添加就不能改cell类型了,但添加前可以通过设置DataGridView 的 RowTemplate 属性来指定新添加的行的每列是什么类型
      

  3.   

    列的类型不可改变必须每列类型统一,如果你希望统一列中单元格显示的风格不一样
    http://www.dotblogs.com.tw/puma/archive/2008/11/10/5943.aspx
      

  4.   

    直接写this.dataGridView1.Rows.Add(4);DataGridViewComboBoxCell c = new DataGridViewComboBoxCell();
    c.Items.Add("aaa");
    c.Items.Add("bbb");
    this.dataGridView1.Rows[0].Cells[1] = c;
                
    this.dataGridView1.Rows[1].Cells[1] = new DataGridViewTextBoxCell();
      

  5.   

    http://www.dotblogs.com.tw/puma/archive/2008/11/10/5943.aspx
      

  6.   

                this.dataGridView1.Rows.Add(4);            DataGridViewComboBoxCell c = new DataGridViewComboBoxCell();
                c.Items.Add("aaa");
                c.Items.Add("bbb");
                DataGridViewButtonCell dgvb = new DataGridViewButtonCell();            this.dataGridView1.Rows[1].Cells[0] = c;
                this.dataGridView1.Rows[0].Cells[0] = dgvi;