How to show set default value for DataGridViewComboBoxCell Value in winform?

前端 未结 2 1927
野的像风
野的像风 2021-01-04 20:37

I have a DataGridView having one DataGridViewComboBoxColumn and I have populated that ComboBox but after clear that DataGridView I hav

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-04 21:38

    You can do this in CellFormatting event

    void dataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
    {
          if (e.ColumnIndex == 0) //Index of your DataGridViewComboBoxColumn 
          {
              e.Value = "Default Value";
          }
    }
    

提交回复
热议问题