DatagridView comboboxcolumn - assign cell value

B

Bill nguyen

I need help to set selected value of combobox column in DGV.

I went this far then got stuck on what to do next:.
How do I set "selected Value" of comboboxpayCode to value of column PayCode
? That is earningCode = payCode.
I can't find .selectedValue in DatagridView ComboboxColumn .

Thanks

Bill

-------------------------
col = .Columns.Add("pCode", "Code")

..Columns(col).Width = 60

..Columns(col).DataPropertyName = "payCode"' Dim comboboxPaycode As New
DataGridViewComboBoxColumn()

..Columns.Insert(4, comboboxPaycode)

..Columns(4).Width = 120

..Columns(4).HeaderText = "Code Desc"

With comboboxPaycode

..DataSource = dCombo.Tables(0)

..ValueMember = "earningCode"

..DisplayMember = "codeDescript"



End With
 
C

Cor Ligthert [MVP]

Bill,

Your question sounds strange for me, you can have thousands of comboboxes in
your datagrid (as you have thousand rows. Do you mean that they should be
all set to a defaultvalue. If it is a new one than just set the value in the
datarow, so it will be automaticly binded to the corresponding value.

Cor
 
B

Bill nguyen

Cor;
I guess my question is not clear. I found the answer to it by setting
..DataPropertyName property

Thanks for your help, as usual.

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top