473,395 Members | 2,006 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,395 software developers and data experts.

Data Grid Clicking

Hi,

How can I tell on the double click event of the datagrid whether or not a
row was double clicked or a column header was double clicked?

My problem is I open a new form on the double click event of the datagrid
based on the selected row. Users however are used to doubleclicking the
column headers to have them automatically resize the column width to see all
of its contents. Unfortunately when they double click the columns headers,
the event is still fired which opens up the form for the selected row.

So, basically if the double click is on the column header and not a row, I
don't want to open my form...but I don't know how to tell if it is the
column header that is double clicked.

Thanks!
Nov 16 '05 #1
3 3948
John,

I would capture the mouse up and mouse down events as well. Every time
the mouse down event or mouse up event occurs, store the coordinates
somewhere. Then, when the double click event fires, pass those coordinates
to the HitTest info. Then, you will know if you are on a row, or a column
or row header.

Granted, there is a slight margin of error here if the user is moving
their mouse erratically while double clicking, but it should work for almost
all cases.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Smith" <js@no.com> wrote in message
news:uD**************@TK2MSFTNGP10.phx.gbl...
Hi,

How can I tell on the double click event of the datagrid whether or not a
row was double clicked or a column header was double clicked?

My problem is I open a new form on the double click event of the datagrid
based on the selected row. Users however are used to doubleclicking the
column headers to have them automatically resize the column width to see
all
of its contents. Unfortunately when they double click the columns
headers,
the event is still fired which opens up the form for the selected row.

So, basically if the double click is on the column header and not a row, I
don't want to open my form...but I don't know how to tell if it is the
column header that is double clicked.

Thanks!

Nov 16 '05 #2
Thanks alot. Good idea. I'll give it a shot.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eS**************@TK2MSFTNGP11.phx.gbl...
John,

I would capture the mouse up and mouse down events as well. Every time the mouse down event or mouse up event occurs, store the coordinates
somewhere. Then, when the double click event fires, pass those coordinates to the HitTest info. Then, you will know if you are on a row, or a column
or row header.

Granted, there is a slight margin of error here if the user is moving
their mouse erratically while double clicking, but it should work for almost all cases.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Smith" <js@no.com> wrote in message
news:uD**************@TK2MSFTNGP10.phx.gbl...
Hi,

How can I tell on the double click event of the datagrid whether or not a row was double clicked or a column header was double clicked?

My problem is I open a new form on the double click event of the datagrid based on the selected row. Users however are used to doubleclicking the
column headers to have them automatically resize the column width to see
all
of its contents. Unfortunately when they double click the columns
headers,
the event is still fired which opens up the form for the selected row.

So, basically if the double click is on the column header and not a row, I don't want to open my form...but I don't know how to tell if it is the
column header that is double clicked.

Thanks!


Nov 16 '05 #3
you can use click event adn then use at that event Hit method to check if a
columnn or row clicked or not

"John Smith" <js@no.com> wrote in message
news:uD**************@TK2MSFTNGP10.phx.gbl...
Hi,

How can I tell on the double click event of the datagrid whether or not a
row was double clicked or a column header was double clicked?

My problem is I open a new form on the double click event of the datagrid
based on the selected row. Users however are used to doubleclicking the
column headers to have them automatically resize the column width to see all of its contents. Unfortunately when they double click the columns headers, the event is still fired which opens up the form for the selected row.

So, basically if the double click is on the column header and not a row, I
don't want to open my form...but I don't know how to tell if it is the
column header that is double clicked.

Thanks!

Nov 16 '05 #4

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

Similar topics

1
by: Linda | last post by:
Hi, I'm new to asp.net and tryign to learn how to work with data grids. I'm retrieving data from a stored procedure and putting it in a data grid. I then want to be able to sort the data when...
3
by: Alice | last post by:
In VB, we can easily configure DB Grid Control's interface by right clicking it and select edit. After that we can edit the column header, adjust the column width and do many other things. ...
2
by: Suresh.P.R | last post by:
I am filling the Data Grid in the existing columns from the database. In the Item_Command event of the Data Grid I am writing the code to be execute while clicking on each item in the data grid. It...
1
by: Josh | last post by:
Using Visual Studio 2003, C#, .NET 1.1. I have a web form with a few textboxes, a couple of dropdown lists, and a data grid. The data grid is populated from a SQL stored procedure. The user...
1
by: veera372 | last post by:
i wants to copy a data from an excel and paste it into a data grid in the web form (asp .net) by clicking the button paste... i think it can be done in java script using clipboard option... but i...
2
by: veera372 | last post by:
hi this is veera, i wants to copy a data from an excel and paste it into a data grid in the web form (asp .net) by clicking the button paste... i think it can be done in java script using clipboard...
2
by: Samuel Shulman | last post by:
Hi Is it possible to add HyperLink functionality to the Image control in the data grid control Thank you, Samuel
16
aspamit
by: aspamit | last post by:
Hi all, I am displaying data in data-grid using dataset.Now I want to select row of data-grid and fetch the values into it in text-boxes on the same page. I mean I want to select the row i.e, by...
4
by: charithana | last post by:
I Loaded data to a Data Grid from a ActiveX Data Controller. Now i want, when i double clicking on a record (Raw in Data grid), and get the raw data to a form or to a report. beter to get in to a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.