不用C#里的Double...........因为这个只能双击那一行里的最前面的头才能............而我是要双击那里面的数据来显示........
请高手指点给一个双击的代码..........谢谢了.
// C#
private void myDataGrid_CurrentCellChanged(object sender,
System.EventArgs e)
{
MessageBox.Show ("Col is " + myDataGrid.CurrentCell.ColumnNumber
+ ", Row is " + myDataGrid.CurrentCell.RowNumber
+ ", Value is " + myDataGrid[myDataGrid.CurrentCell] );
}
Visual C# 说明 确保存在启用事件处理程序所需的代码。在这种情况下,它类似于以下内容:
this.myDataGrid.CurrentCellChanged += new
System.EventHandler(this.myDataGrid_CurrentCellChanged);
// C#
private void myDataGrid_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
DataGrid myGrid = (DataGrid) sender;
System.Windows.Forms.DataGrid.HitTestInfo hti;
hti = myGrid.HitTest(e.X, e.Y);
string message = "You clicked ";
switch (hti.Type)
{
case System.Windows.Forms.DataGrid.HitTestType.None :
message += "the background.";
break;
case System.Windows.Forms.DataGrid.HitTestType.Cell :
message += "cell at row " + hti.Row + ", col " + hti.Column;
break;
case System.Windows.Forms.DataGrid.HitTestType.ColumnHeader :
message += "the column header for column " + hti.Column;
break;
case System.Windows.Forms.DataGrid.HitTestType.RowHeader :
message += "the row header for row " + hti.Row;
break;
case System.Windows.Forms.DataGrid.HitTestType.ColumnResize :
message += "the column resizer for column " + hti.Column;
break;
case System.Windows.Forms.DataGrid.HitTestType.RowResize :
message += "the row resizer for row " + hti.Row;
break;
case System.Windows.Forms.DataGrid.HitTestType.Caption :
message += "the caption";
break;
case System.Windows.Forms.DataGrid.HitTestType.ParentRows :
message += "the parent row";
break;
}
Console.WriteLine(message);
}
Visual C# 说明 确保存在启用事件处理程序所需的代码。在这种情况下,它类似于以下内容:
this.myDataGrid.MouseDown += new
System.Windows.Forms.MouseEventHandler
(this.myDataGrid_MouseDown);