Grid

  • Thread starter Thread starter xp
  • Start date Start date
X

xp

I have a datagrid on my VB.Net form. I am trying to use
the DblClick event of the grid, but when I run the program
and double click on the grid, the event was not evoked.
Why?

Thanks
xp
 
I have experienced this as well. If you double click on the row or column
headers, double click on a space where there are no cells or double click
inbetween the cells when the cursor is just the arrow then the DataGrid
will get this event. What I think happens when you double click in a cell
is the DataGrid cell which in this case is probably a TextBox gets the
double click event.

One possible solution would be to set the DataGrid.TableStyles property
with a TableStyle that has the ColumnStyles property with
DataGridTextBoxColumn for each column. With DataGridTextBoxColumn you can
get a reference to the underlying textbox with the TextBox property. This
might work something like the following:

DataGrid dg = new DataGrid();
TableStyle ts = new TableStyle();
DataGridTextBoxColumn textColumn;

for(int i=0; i<Number_Of_Columns; i++) {
textColumn= new DataGridTextBoxColumn();
textColumn.TextBox.DoubleClick += new
EventHandler(MyDoubleClickEventHandler);
ts.ColumnStyles.Add(textColumn);
}

dg.TableStyles.Add(ts);

Ryan Byington [MS]

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

--------------------
 
Back
Top