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 }