473,320 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

DoubleClick Handler

Hi All,

Am just getting into handlers at the moment and had a question. How
would I write the code (the 'public void example handles cell
doubleclick...) for a method to handle a double click in any cell of a
particular datgridview column?

Thanks for any help.

Jul 19 '07 #1
2 3081
There's two steps :

1. Add a new event handler to the CellDoubleClick event of your datagrid :

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

2. Create the event handler method dataGridView1_CellDoubleClick

private void dataGridView1_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 3)
// TODO
}

Using the column index is not a good solutin, you can get the instance of
the DataGridViewColumn from the Columns property of your DataGrid like this :
dataGridView1.Columns["MyColumn"]
and then use the Index property of the returned column.

"Looch" wrote:
Hi All,

Am just getting into handlers at the moment and had a question. How
would I write the code (the 'public void example handles cell
doubleclick...) for a method to handle a double click in any cell of a
particular datgridview column?

Thanks for any help.

Jul 19 '07 #2

"Vko" <Vk*@discussions.microsoft.comwrote in message
news:92**********************************@microsof t.com...
There's two steps :

1. Add a new event handler to the CellDoubleClick event of your datagrid :

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

2. Create the event handler method dataGridView1_CellDoubleClick

private void dataGridView1_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 3)
// TODO
}

Using the column index is not a good solutin, you can get the instance of
the DataGridViewColumn from the Columns property of your DataGrid like
this :
dataGridView1.Columns["MyColumn"]
and then use the Index property of the returned column.
Or retrieve dataGridView1.Columns[e.ColumnIndex] and then do whatever tests
you need.

However, I think you can set event handlers on a per-table, per-column,
per-row, and per-cell basis, so setting the handler for just one column
might be best.
>
"Looch" wrote:
>Hi All,

Am just getting into handlers at the moment and had a question. How
would I write the code (the 'public void example handles cell
doubleclick...) for a method to handle a double click in any cell of a
particular datgridview column?

Thanks for any help.


Jul 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JoeHenrich | last post by:
I am using VS.NET 2003 and am having an interesting issue with a Listbox control. Essentially, I have a form with a listbox on it. In the listbox doubleclick event I would like to do some...
0
by: Koo Min | last post by:
Hello, I've added drag-and-drop feature to a windows forms label control which is contained in a panel. And I added a doubleclick event handler to the drag-and-drop-abled label, but doubleclick...
7
by: Sue & Bill | last post by:
Does a double click action also generate two MouseUp events? If so, what is a good method in my MouseUp event handler to detect that a MouseUp is part of a double click action? Thanks in...
4
by: Tor Inge Rislaa | last post by:
DoubleClick in DataGrid Hi I have a Datagrid bound to a dataset that I want to write a DoubleClick procedure on. My problem is that the DoubleClick event is raised only when DoubleClicking the...
3
by: LCAdeveloper | last post by:
Help! A trawl through the archives couldn't shed any light on this, so is there a way to handle DoubleClick events for RadioButtons in vb.NET? I'm recoding a VB4 application, which used the...
3
by: C Glenn | last post by:
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...
4
by: _DD | last post by:
TrackBar DoubleClick event is not accessible via the Control Properties event pane. So I tried adding the handler directly: this.ColTrackBar.DoubleClick += new...
5
by: celestialgal86 | last post by:
Hi everyone... I'm a starter at .Net programming, and I need some help. I was asked to develop a console app that will auto-hide the console window and show a system tray icon. And by...
3
by: Zytan | last post by:
I can handle DoubleClick on a ListBox to respond, not when the selection changes, but when you double click one to invoke an action. This is the same as using the keys to move the selection, then...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.