日期:2014-05-18 浏览次数:21103 次
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];
            }
        }