0
votes

I have a datagridview which have a ComboBoxCell,,, ComboBox is bound to data,, I want to use it as Traditional ComboBox,, i mean i want to display its Item (from display members) on the base of its value,,

for example

When i do this

Datagridview1.CurrentRow.Cells(4).value = 7 'Cell 4 is the DatagridviewComboBoxCell

It gives me the error that

"DatagridviewComboBoxCell.value is not valid",

But I want that this combobox should Select And Display the item which value is 7

I have tried manay different techniques,,, but in vain

Thanks,,

1
Long-shot here, but value isn't capitalized. May just be a typo for the question, but it's worth mentioning as those are the kinda mistakes I make, spend 2 hours looking for it and then smh. =)Yatrix
didnt got ur point,, wat u want to say??? YatrixMalik
DatagridviewComboBoxCell.value should be DatagridviewComboBoxCell.Value if Value is a real property.Yatrix
Its Vb.Net and its not Case Sensitive,,,, so its not the solution,,Malik
Well, best of luck to you then.Yatrix

1 Answers

0
votes

Well I know it's kind of late, I hope that I don't wake you. This might help.

    For Each question As String In questions

        answerStr = 'your query or something that can be used as a datasource, eg datatable'
        Dim dgvcc As New DataGridViewComboBoxCell
        With dgvcc
            .DataSource = answerStr
            .ValueMember = "ColumnIDFromAnswerStr"
            .DisplayMember = "AnotherColumnFromAnswerStr"
        End With    

        'this is where you can set the combobox
        'assuming answerStr is a datatable (not tested code, but i think it will work)
        dgvcc.Value = answerStr.Rows(x).Item(y).Value    
        'assuming you only have one column (combobox)   
        DataGridView1.Item(0, rowIndex) = dgvcc      
        rowIndex += 1
        dgvcc.Dispose()
    Next

EDIT

I Also found this useful link