我正在尝试访问用于在此方法中填充 DataGridview 的对象:
void memberDataGridView_SelectionChanged(object sender, EventArgs e)
{
foreach (DataGridViewCell cell in memberDataGridView.SelectedCells)
{
foreach (DataGridViewRow row in memberDataGridView.Rows)
{
if (row.Cells.Contains(cell))
{
//here is where I want to access the object that was used to build this row.
//it will be added as a comboboxitem
}
}
}
这是使用 DataTable 添加到 gridview 的对象的代码
DataRow row = _loadMembersTable.NewRow();
row["Member Name"] = member.InternalLabel;
row["Type"] = member.MemberType;
_loadMembersTable.Rows.Add(row);
memberDataGridView.DataSource = _loadMembersTable;
当我在 selectionChanged 中需要它时,构建 DataTable 以找到该成员对象时,我该怎么办?