在C#.net 2005中的DataGridView中 怎样给手工添加上去的ComboBoxColumn添加选项

解决方案 »

  1.   

    可以在编辑列对经重新绑定一个数据源,和comboBox的绑定数据源方法一样
      

  2.   

    手动绑定的默认名称为column1
    this.column1.datasource=..
      

  3.   

    得到这个列,转换成DataGridViewComboBoxColumn,然后就可以绑定了.或者往Items里追加。
      

  4.   

    ComboBox列我是这样写上去的。在哪儿给ComboBox加行就不知道了。
    DataGridViewComboBoxColumn den;
    den = new DataGridViewComboBoxColumn();//单元格实例化成列
    den.DataPropertyName = "汇总级";//绑定数据表的相应列
    den.ReadOnly = false;
    den.Name = "汇总级";
    den.Tag = "";
    den.HeaderText = "汇总级";
    den.Width = 60;
    den.SortMode = DataGridViewColumnSortMode.NotSortable;
    den.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//表格内容对齐方式
    den.DefaultCellStyle.SelectionForeColor = Color.Black;
    den.DefaultCellStyle.SelectionBackColor = Color.Bisque;
    den.DefaultCellStyle.ForeColor = Color.Black;
    den.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;//表头对齐方式
    this.dataGridView1.Columns.Add(den);
      

  5.   

    System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
    dataGridViewCellStyle1.NullValue = "明细";
    den.DefaultCellStyle = dataGridViewCellStyle1;
    den.Items.AddRange(new object[] {
    "一级",
    "二级",
    "三级",
    "明细"});谢谢大家,问题解决掉了。