The primary reason why the double-click event of the cell row of the DataGrid does not work is that the DataGrid treats a cell as a TextBox, so no double-click event is generated.
The code for the solution is as follows:
DataGrid dg = this. Maid;
Dg. TableStyles. Clear ();
DataGridTableStyle tableStyle = new DataGridTableStyle ();
TableStyle. MappingName = "whp ";
// Set attributes
TableStyle. AlternatingBackColor = Color. LightGray;
Maid ();
TextStyle. MappingName = "ID ";
TextStyle. HeaderText = "ID ";
TextStyle. Width = 0;
Dg. MouseDown + = new System. Windows. Forms. MouseEventHandler (dg_MouseDown );
// Add an event Processor
TextStyle. TextBox. MouseDown + = new MouseEventHandler (TextBoxMouseDownHandler );
TextStyle. TextBox. DoubleClick + = new EventHandler (TextBoxDoubleClickHandler );
TableStyle. GridColumnStyles. Add (textStyle );
TextStyle = new maid ();
TextStyle. MappingName = "name ";
TextStyle. HeaderText = "name ";
TextStyle. Width = 660;
// Add an event Processor
TextStyle. TextBox. MouseDown + = new MouseEventHandler (TextBoxMouseDownHandler );
TextStyle. TextBox. DoubleClick + = new EventHandler (TextBoxDoubleClickHandler );
TableStyle. GridColumnStyles. Add (textStyle );
Dg. TableStyles. Add (tableStyle );
Dg. DataSource = SQL. CasehxmQueryResult (conditionName, likeName). Tables ["whp"]. DefaultView;
}
Private void TextBoxDoubleClickHandler (object sender, EventArgs e)
{
Int id = Convert. ToInt32 (maid [maid. RowNumber, 0]);
ShowWebBrowser (id );
}
Private void TextBoxMouseDownHandler (object sender, MouseEventArgs e)
{
If (DateTime. Now <gridMouseDownTime. AddMilliseconds (SystemInformation. DoubleClickTime ))
{
Int id = Convert. ToInt32 (maid [maid. RowNumber, 0]);
ShowWebBrowser (id );
}
}
Private void dg_MouseDown (object sender, System. Windows. Forms. MouseEventArgs e)
{
GridMouseDownTime = DateTime. Now;
}