none
Datagridviewcomboboxcolumn Default Value RRS feed

  • Question

  • Hi,

    I manually added a datagridviewcomboboxcolumn to my grid:

    Dim cboCol As New DataGridViewComboBoxColumn

    cboCol.Items.AddRange(New Object() {"Internal", "External"})

    cboCol.Name = "cboCol"

    Me.dgAvail.Columns.Add(cboCol)

    It shows up in the last column of my grid.  Currently when I load the form it shows up with no value showing and I need to select the dropdown to enter a value (fine, but....)

    I would like it to show a default value (so the user only has to change when necessary). 

    How can I acheive this?  It seems the only time I can set the selected index is when it is in the EditingControlShowing event but that event is only fired when the user selects the cell.  I need to get to the selected index after I add the column.  I tried  doing this in the column added event, but it will not let me convert the column to a combo box.

    If e.Column.CellType.Name = "DataGridViewComboBoxCell" Then

        Dim cbo As combobox  = CType(e.Column, combobox)

    Any help would be great,

    Thanks,

    Sunday, March 12, 2006 5:18 PM