首页 > 代码库 > DevExpress gridview获取单元格坐标

DevExpress gridview获取单元格坐标

获取坐标(在RowCellClick事件中)的代码如下:

 private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)        {            //获取点击单元格左上角的坐标            GridViewInfo info = gridView1.GetViewInfo() as GridViewInfo;            GridCellInfo cellInfo = info.GetGridCellInfo(gridView1.FocusedRowHandle, gridView1.FocusedColumn);            string m= cellInfo.Bounds.X.ToString();            string m2 = cellInfo.Bounds.Y.ToString();            //获取鼠标点击时的坐标            Point p = this.gridControl1.PointToClient(Control.MousePosition);            string n = p.X.ToString();            string n2 = p.Y.ToString();            MessageBox.Show("单元格坐标:"+ m+","+m2+"\n"+"鼠标坐标:"+n+","+n2);        }