Today I’ve been wondering how to set a DataGridViewComboBoxColumn to a default value. The reason I wanted do this, is because i want the combo box to have a default value when the datagridview is loaded in the screen.
The line to accomplish this is the following:
DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
cmb.DefaultCellStyle.NullValue = "Buy";
January 30th, 2009 at 7:12 pm
And does it really work?
I have 2 items: 16 and 7, and I’ve set nullvalue to 16. When I try to get the cell value I obtain null when 16 is selected, and 7 in the case of 7.