471,316 Members | 1,009 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

DoubleClick on DataGrid

I would like one DoubleClick event handler to handle all double clicks
throughout a DataGrid. I've assigned a DoubleClick event handler to the
DataGrid and it works nifty-spiffy so long as I click outside the data.
The trouble is, the underlying cells or columns or whatever would like
to have something to say about this. The cells respond to the
DoubleClick but not the grid.

How do I get my event handler to handle all double clicks within the grid?
Dec 13 '05 #1
3 8104
Hi Glenn,

I've tried this out and it seems that by implementing DoubleClick the event
will be fired whenever you double click anywhere on the DataGrid, cells and
all. One thing to note though is that if you have CellDoubleClick as well as
DoubleClick implemented first DoubleClick will fire and then immediately
CellDoubleClick will fire when you double click on a cell. Could this be
causing some problems for you? Let me know if it helped. Good Luck!

"C Glenn" wrote:
I would like one DoubleClick event handler to handle all double clicks
throughout a DataGrid. I've assigned a DoubleClick event handler to the
DataGrid and it works nifty-spiffy so long as I click outside the data.
The trouble is, the underlying cells or columns or whatever would like
to have something to say about this. The cells respond to the
DoubleClick but not the grid.

How do I get my event handler to handle all double clicks within the grid?

Dec 14 '05 #2
This appears to be the problem, but what and where is CellDoubleClick?
I can't find it in the list of events for the DataGrid. It does appear
though that when I DoubleClick on a Cell the native DoubleClick behavior
for the cell is invoked instead of the DoubleClick code that I've written.

Any suggestions for getting around this will be greatly appreciated.

Justin Swan (MSFT) wrote:
Hi Glenn,

I've tried this out and it seems that by implementing DoubleClick the event
will be fired whenever you double click anywhere on the DataGrid, cells and
all. One thing to note though is that if you have CellDoubleClick as well as
DoubleClick implemented first DoubleClick will fire and then immediately
CellDoubleClick will fire when you double click on a cell. Could this be
causing some problems for you? Let me know if it helped. Good Luck!

"C Glenn" wrote:

I would like one DoubleClick event handler to handle all double clicks
throughout a DataGrid. I've assigned a DoubleClick event handler to the
DataGrid and it works nifty-spiffy so long as I click outside the data.
The trouble is, the underlying cells or columns or whatever would like
to have something to say about this. The cells respond to the
DoubleClick but not the grid.

How do I get my event handler to handle all double clicks within the grid?

Dec 14 '05 #3
the CellDoubleClick event appears in the events tab for me when the DataGrid
object is selected, which version of VS are you using? As a workaround you
could try using code something like this in the form.cs file which should
force the call to double click if CellDoubleClick is the only event being
called at the moment. Obviously if both events are actually firing you will
get DoubleClick called twice with this.

private void dataGridView1_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)
{
dataGridView1_DoubleClick(sender, new EventArgs());
}

You will also need to include the following in the form.designer.cs file:

this.dataGridView1.CellDoubleClick += new
System.Windows.Forms.DataGridViewCellEventHandler( this.dataGridView1_CellDoubleClick);

If this doesn't help then some details on your DoubleClick implementation
might be useful in discovering why it's not working in this situation. Good
Luck!

"C Glenn" wrote:
This appears to be the problem, but what and where is CellDoubleClick?
I can't find it in the list of events for the DataGrid. It does appear
though that when I DoubleClick on a Cell the native DoubleClick behavior
for the cell is invoked instead of the DoubleClick code that I've written.

Any suggestions for getting around this will be greatly appreciated.

Justin Swan (MSFT) wrote:
Hi Glenn,

I've tried this out and it seems that by implementing DoubleClick the event
will be fired whenever you double click anywhere on the DataGrid, cells and
all. One thing to note though is that if you have CellDoubleClick as well as
DoubleClick implemented first DoubleClick will fire and then immediately
CellDoubleClick will fire when you double click on a cell. Could this be
causing some problems for you? Let me know if it helped. Good Luck!

"C Glenn" wrote:

I would like one DoubleClick event handler to handle all double clicks
throughout a DataGrid. I've assigned a DoubleClick event handler to the
DataGrid and it works nifty-spiffy so long as I click outside the data.
The trouble is, the underlying cells or columns or whatever would like
to have something to say about this. The cells respond to the
DoubleClick but not the grid.

How do I get my event handler to handle all double clicks within the grid?

Dec 14 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by JoeHenrich | last post: by
5 posts views Thread by David Lozzi | last post: by
1 post views Thread by Duke | last post: by
4 posts views Thread by Tor Inge Rislaa | last post: by
2 posts views Thread by Looch | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.