|
@@ -0,0 +1,32 @@
|
|
|
+using System.Windows.Forms;
|
|
|
+using DevExpress.XtraGrid.Views.Grid;
|
|
|
+using DevExpress.XtraGrid.Views.Grid.ViewInfo;
|
|
|
+
|
|
|
+namespace WinFormDemo
|
|
|
+{
|
|
|
+ class GridViewGridHitInfo
|
|
|
+ {
|
|
|
+ public void demo()
|
|
|
+ {
|
|
|
+ GridView gv = new GridView();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * GridView 鼠标双击获取双击到的单元格信息
|
|
|
+ * */
|
|
|
+
|
|
|
+ gv.MouseDown += (s, e) =>
|
|
|
+ {
|
|
|
+ if (e.Button != MouseButtons.Left || e.Clicks != 2) return; //不是双击
|
|
|
+
|
|
|
+ if (gv.State == GridState.ColumnDown) return; //是否列标题
|
|
|
+
|
|
|
+ GridHitInfo info = gv.CalcHitInfo(e.X, e.Y);
|
|
|
+ if (info.HitTest == GridHitTest.RowCell) //双击单元格
|
|
|
+ {
|
|
|
+ string columnName = info.Column.FieldName; //点击的列
|
|
|
+ int rowIndex = info.RowHandle; //点击的行
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|