获取DataGridView 的 DataGridViewComboBoxCell单元格的显示值和基础值
DataGridViewCell cell = dataGridView.Rows[r].Cells[c];//得到单元格
if (cell is DataGridViewComboBoxCell)
{
DataGridViewComboBoxCell cb = cell as DataGridViewComboBoxCell;
string showValue = ((System.Data.DataRowView)cb.Items[n])[cb.DisplayMember].ToString();//显示值
string baseValue = ((System.Data.DataRowView)cb.Items[n])[cb.ValueMember].ToString();//基础值
//cell.Value是下拉框的索引值
}
本文介绍如何从DataGridView中的DataGridViewComboBoxCell单元格获取显示值和基础值。通过具体代码示例展示了如何针对指定行和列的单元格,读取其下拉列表中的特定项的显示文本和基础数据。
2151





