至高吴上(Alfa.wu)

一个人,一生,能坚持做好一件事情是多么的牛XX啊!!!

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

c1flexgrid 通过 HitTestInfo 根据坐标 取得所在行

 

 1         private void c1FlexGrid1_Click(object sender, EventArgs e)
 2         {
 3             MouseEventArgs mouseEvent = e as MouseEventArgs;
 4             if (mouseEvent.Button == MouseButtons.Left)
 5             {
 6                 if (c1FlexGrid1.Rows != null && c1FlexGrid1.Rows[c1FlexGrid1.RowSel]["YN"] != null &&  c1FlexGrid1.RowSel > 0 )
 7                 {
 8                     HitTestInfo hti = c1FlexGrid1.HitTest(mouseEvent.Location);
 9                     int currentRowIndex = hti.Row; // 也可以通过 c1FlexGrid1.RowSel,但是这个当你在点击空白处的时候,还是取得之前的停留的焦点行列信息
10                     string ynValue = c1FlexGrid1.Rows[currentRowIndex]["YN"].ToString().Trim();
11                     if (ynValue == "1")
12                     {
13                         ynValue = "0";
14                     }
15                     else
16                     {
17                         ynValue = "1";
18                     }
19 
20                     c1FlexGrid1.Rows[currentRowIndex]["YN"] = ynValue;
21                 }
22             }
23         }

 

posted on 2012-06-28 19:46  Alfa  阅读(580)  评论(0编辑  收藏  举报