回答

2

可以使用CellFormatting事件来改变任何显示的值:

//attach in code or via designer: 
dataGridView1.CellFormatting += new DataGridViewCellFormattingEventHandler(dataGridView1_CellFormatting); 


    //example implementation: 
    void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) 
    { 
     if (e.ColumnIndex == Column1.Index && e.Value==null)//where Column1 is your combobox column 
     { 
      e.Value = "Empty"; 
      e.FormattingApplied = true; 
     } 
    } 
+0

如果我的价值改变的东西,是不是在数据绑定列表,然后我得到一个错误。 – Daniel

+0

有没有其他想法?问题是DataGridViewComboBoxCell没有文本属性。该值是数据绑定的,因此无法为其分配文本。 – Daniel

+0

如果e.FormattingApplied = true,你可以试试吗?设置? (也编辑原帖以便添加) –

相关问题