简体   繁体   中英

Bind Data To combo box column in DataGridView C#

I have a DataGridView with combo box column. For the combo box column I want to bind GroupName and GroupId. I'm binding GroupName as display member.

dgvRoster[j, i].Value = GroupName;  

How can I bind GroupId as Value Member?

this.DataGridViewComboBoxColumn.DisplayMember = "Name";
this.DataGridViewComboBoxColumn.ValueMember = "ID";
this.DataGridViewComboBoxColumn.DataPropertyName = "ID";

i believe this is what you are missing. i also suggest you take a look here Binding a combobox inside a datagridview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM