【发布时间】:2016-09-17 20:41:14
【问题描述】:
已经很久没有计划了。刚刚学习 VB 2008,自 1999 年以来情况发生了变化。
我有 3 个数据网格。我想将所有 3 行点击分组到一个区域并获取 CurrentRowIndex。
那么你可以通过一个控件名称来获取3个网格的CurrentRowIndex吗?
我知道这不起作用:
private void tblCollectionDataGrid_Click(object sender, EventArgs e)
{
Control control = (Control)sender;
MessageBox.Show(control.Name);
row = control.Name.CurrentRowIndex;
}
或者你必须把每一个都打出来? 这可行,但......如果可能的话,希望它更简单。
private void tblCollectionDataGrid_Click(object sender, EventArgs e)
{
Control control = (Control)sender;
MessageBox.Show(control.Name);
switch (control.Name)
{
case "tblMemoDataGrid":
row = tblMemoDataGrid.CurrentRowIndex;
break;
case "tblReportDataGrid":
row = tblReportDataGrid.CurrentRowIndex;
break;
case "tblInfoDataGrid":
row = tblInfoDataGrid.CurrentRowIndex;
break;
}
}
【问题讨论】:
标签: c# datagrid windows-mobile-5.0