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
--------------------
Content-Class: urn:content-classes:message
From: "xp" <gp**@shaw.ca>
Sender: "xp" <gp**@shaw.ca>
Subject: Grid
Date: Wed, 6 Aug 2003 15:52:52 -0700
Lines: 7
Message-ID: <04****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcNcbXdvhEHy8bZ2Q6KpwSaQyJEKWQ==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:103781
NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
X-Tomcat-NG: microsoft.public.dotnet.general
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