I have created a dropdown in my grid using the below code. It only needs to
display 2 values. The below allows me to acheive this, however, I want to be
able to have the first item be the default item. In a real combobox I would
just set the selectedIndex =0. It does not seem to be that easy to do in
this case, or intuitive. There is no selectedIndex, selectedItem, text,
etc. I even tried to work with the DataGridViewComboBoxCell, but again, not
very intuitive. This should not be complicated.
Can Anyone help me out here, All i want the dropdown to do is on load to
have the first item visible, currently the below loads with no items
selected, user has to select manually.
'Add Internal External DropDown
Dim cboCol As New DataGridViewComboBoxColumn
cboCol.Items.AddRange(New Object() {"Internal", "External"})
cboCol.Name = "cboCol"
Me.dgAvail.Columns.Add(cboCol)
Re: DataGridViewComboBoxColumn -
07-11-2006
, 08:15 AM
Hi there,
use this:
Dim ComboBoxColumn As New DataGridViewComboBoxColumn()
Dim myValues As String() = {"Internal", "External"}
With ComboBoxColumn
.Items.AddRange(myValues)
.DefaultCellStyle.NullValue = "Internal"
End With