break

C#:ComboBoxColumn default value

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";

One Response

  1. Victor Says:

    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.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

CAPTCHA Image
Reload Image