By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,738 Members | 1,730 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,738 IT Pros & Developers. It's quick & easy.

DoubleClick on DataGrid

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.