Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting double-click in datagrid columns

Status
Not open for further replies.

MasterRacker

Active member
Oct 13, 1999
3,343
US
I have an application where I'm bringing up a summary list of contacts in a datatable bound to a datagrid. The idea is for the user to select a row and view detailed information about that contact. I have that working both from a "View" button and double-clicking one of the row selectors in the leftmost portion of the datagrid.

I am displaying 3 columns in the grid and the problem is that double-clicking out in the data (say name or phone number) does not fire the double-click event for the grid. Normal grid behavior does change the selected row, but my question is how do I detect the double-click anywhere in the grid to pull up the second form?

Jeff
[purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day

I was not born cynical - I earned my cynicism through careful observation of the world around me.
 
I was surprised no one answered this. After further digging, I managed to find one description of this problem. According to the article I found, the problem is that the DataGrid picks up the first click, but that click activates the cell underneath it, which them picks up the second click. This means that neither the grid, nor the underlying cell (in my case, a textbox) sees a double-click.

The solution presented was to record the time of a mousedown on the grid. The grid needs to have a custom table style created so that each column can also have a mousedown handler defined that records the time. The column mousedown methods compares the difference between it's time and the grid mouse down. If the difference is less than the systems defined doubleclick interval, a double-click occured. Each column also needs a double-click event handler in case the box was already active, then double-clicked.

This seems like a clunky solution, but it at least makes sense and the code is not involved.

It's a much less trivial problem than I first thought.

Jeff
[purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day

I was not born cynical - I earned my cynicism through careful observation of the world around me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top