I have an urgent question about the datagridview and combobox column in VB2005 I am unable to show the first item in the award code field by default without selecting an item first. How can this be done? For example CX should be shown in the blank area for the first 2 items, which shows up as blank. The 2nd issue is how can I take the data from my hidden field, which has an award code of either cd,cn,mr, etc, which is brought back in the dataset below and is on the grid but the column is just hidden. I actually need this data shown as the default in the “blank space” of the combobox. I am at a loss. So basically when I load the grid I need the award code for a specific row placed into the combo box as if it were selected for that specific row by default. So row 1 would show the following: Row 1 would show Transfer =blank Rfa number CX08-004 Award Code=CD Row 2 would show Transfer =blank Rfa number CX08-003 Award Code=RP etc etc Below code is what I use to bind the datasource to the combo box With grdBatchBudgetProjection ‘Dataviewgrid With chk ‘CheckboxColumn .DataPropertyName = "AwardCD" .HeaderText = "Award Code" .Width = 100 ' Bind Column .DataSource = ds3.Tables(0) .ValueMember = "AwardID" ‘also tried AwardCD here .DisplayMember = "AwardCD" .DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox 'dd or cbo, doesn't really matter for this field. End With .Columns.Add(chk) End With ----------------- I also tried the below code with no success. i just cannot see what I am doing incorrectly.
'Kludge loop to have combo box index= value returned from sql
'For iRowCount = 0 To ds2.Tables(0).Rows.Count - 1
Dim j As Integer = 0
For Each row As DataGridViewRow In grdBatchBudgetProjection.Rows
'' Dim Cell As DataGridViewComboBoxCell = DirectCast(grdBatchBudgetProjection.Item(5,j),
DataGridViewComboBoxCell)
Dim cell As DataGridViewComboBoxCell = DirectCast(grdBatchBudgetProjection.Item(5, j),
DataGridViewComboBoxCell)
cell.Value = ds2.Tables(0).Rows(j)(4).ToString
'Debug.Print(ds2.Tables(0).Rows(j)("AwardCD").ToString)