Set default value for DataGridView ComboBox

╄→гoц情女王★ 提交于 2019-12-02 03:26:10

To set default value for cell you can use either of these options:

  • Handle DefaultValuesNeeded event of grid and assign value to e.Row.Cells["Job"].Value
  • In your DataTable set the DefaultValue for the 'Job' DataColumn to desired value

In both options, the type of value which you assign should be the same type as DataType of the column.

Note: You should know e.Row.Cells["Job"] is not DataGridViewComboBoxColumn. If the column is combo box, then the cell is DataGridViewComboBoxCell.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!