110,502
社区成员
发帖
与我相关
我的任务
分享
private void dataGridView_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
try
{
this.toolStripStatusLabel7.Text = Convert.ToString(e.RowIndex + 1);
this.toolStripStatusLabel9.Text = Convert.ToString(e.ColumnIndex + 1);
}
catch { }
}
private void dataGridView_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.RowIndex + 1 < Int32.Parse(this.toolStripStatusLabel7.Text))
{
this.toolStripStatusLabel11.Text = this.toolStripStatusLabel7.Text;
this.toolStripStatusLabel7.Text = Convert.ToString(e.RowIndex + 1);
}
else
{
this.toolStripStatusLabel11.Text = Convert.ToString(e.RowIndex + 1);
}
if (e.ColumnIndex + 1 < Int32.Parse(this.toolStripStatusLabel9.Text))
{
this.toolStripStatusLabel13.Text = this.toolStripStatusLabel9.Text;
this.toolStripStatusLabel9.Text = Convert.ToString(e.ColumnIndex + 1);
}
else
{
this.toolStripStatusLabel13.Text = Convert.ToString(e.ColumnIndex + 1);
}
}
我变通了一下,通过状态栏来记录选择的范围,删除的时候就遍历一下这些范围的单元格就可以了