c#WinForm中通过鼠标点DataGrid事件获取DataGrid Cell数据

来源:互联网 发布:高质量java程序设计 编辑:程序博客网 时间:2024/06/16 16:24

      有好一段时间不做.net的WinForm 程序了,.net 在WinForm中的DataGrid控件用起来,总觉得

和VC++,VB6中的DataGrid命名区别太大!而且用法有点怪异!

     我想实现的一个功能是,用户鼠标点DataGrid中的一行数据的时候,系统默认选中该数据,

然后可以进行删除操作。程序代码如下:

  private void dataGridScore_DoubleClick(object sender, System.EventArgs e)
  {
         pUserID=dataGridScore[dataGridScore.CurrentCell.RowNumber,0].ToString();
         labSelectUser.Text="当前选中["+pUserID+"]的积分记录";    
  }

 

获取Cell的信息是用DataGrid[row,cell]语法格式来获取信息!一下子还真不习惯!