星空网 > 软件开发 > ASP.net

单击单元格任意地方事件

当我们在进行修改的时候,点击数据行,数据则会自动传送到相应的文本框中如图所示单击单元格任意地方事件

 

 

  1. //单击单元格任意地方事件
  2.         private void dgv_view_CellClick(object sender, DataGridViewCellEventArgs e)
  3.         {
  4.             int rowIndex = this.dgv_view.CurrentCell.RowIndex;
  5.             if (rowIndex > -1)
  6.             {
  7.                 if (this.dgv_view[0, rowIndex].Value.ToString() != string.Empty)
  8.                 {
  9.                      stu_id = Convert.ToInt32(this.dgv_view[0, rowIndex].Value.ToString());
  10.                     this.txt_name.Text = this.dgv_view[1, rowIndex].Value.ToString();
  11.                     this.txt_age.Text = this.dgv_view[2, rowIndex].Value.ToString();
  12.                     if (this.dgv_view[4, rowIndex].Value.ToString() == "男")
  13.                         this.rdo_man.Checked = true;
  14.                     else
  15.                         this.rdo_gdenman.Checked = true;
  16.                     this.cbo_class.Text = this.dgv_view[3, rowIndex].Value.ToString();
  17.                     this.txt_address.Text = this.dgv_view[5, rowIndex].Value.ToString();
  18.                 }
  19.                 else
  20.                 {
  21.                     MessageBox.Show("请选择数据行!");
  22.                     return;
  23.                 }
  24.             }
  25.         }



原标题:单击单元格任意地方事件

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流