110,536
社区成员
发帖
与我相关
我的任务
分享
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
List<int> lstIndex = new List<int>();
foreach (DataGridViewTextBoxCell cell in dataGridView1.SelectedCells)
{
if (!lstIndex.Contains(cell.RowIndex))
{
lstIndex.Add(cell.RowIndex);
}
}
if (lstIndex.Count > 0)
{
lstIndex.Sort();
//第一行
int firstRow = lstIndex[0];
//最后行
int lastRow = lstIndex[lstIndex.Count - 1];
}
}