473,387 Members | 1,572 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,387 software developers and data experts.

DataGrid - Detecting which cell was clicked

Hello,
How would one go about detecting which row/column was clicked in a datagrid.
I'm sure it can be done but I can't figure it out.
Thanks
Nov 15 '05 #1
3 1505
hi there

try something like this:

private void dataGridAdresse_Click(object sender,
System.Windows.Forms.MouseEventArgs e)
{
string strRowColumn = null;
Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = dataGridAdresse.HitTest(pt);
// right mouse
if(e.Button == MouseButtons.Right)
{
MessageBox.Show("Bitte mit der linken Maustaste anklicken," +"\n um das
Detail dieser Zeile anzuzeigen");
}
// left mouse
if(e.Button == MouseButtons.Left)
{
if(hti.Type == DataGrid.HitTestType.Cell)
{
strAdressenNummer = (dataGridAdresse[hti.Row, 0].ToString());
strRowColumn = "Column: " + hti.Column.ToString();
strRowColumn += ", Row: "+ hti.Row.ToString();
}
}
}

i hope this helps a bit to get on track !!

jonas knaus

jo*********@naviti.ch

"Randy" <rf*****@bellsouth.net> schrieb im Newsbeitrag
news:OB*************@TK2MSFTNGP10.phx.gbl...
Hello,
How would one go about detecting which row/column was clicked in a datagrid. I'm sure it can be done but I can't figure it out.
Thanks

Nov 15 '05 #2
You can also trap DataGrid.CurrentCell on mouseDown. It has two params,
RowNumber and COlumnNumber.
"Randy" <rf*****@bellsouth.net> wrote in message
news:OB*************@TK2MSFTNGP10.phx.gbl...
Hello,
How would one go about detecting which row/column was clicked in a datagrid. I'm sure it can be done but I can't figure it out.
Thanks

Nov 15 '05 #3
Thanks for the help guys. I'm going to look at both ways.
Thanks again...Have a good day!
"Randy" <rf*****@bellsouth.net> wrote in message
news:OB*************@TK2MSFTNGP10.phx.gbl...
Hello,
How would one go about detecting which row/column was clicked in a datagrid. I'm sure it can be done but I can't figure it out.
Thanks

Nov 15 '05 #4

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

Similar topics

14
by: Jack Kaufmann | last post by:
I am trying to verify a datagrid in which there must be an entry in both columns of any new row, and those values must be greater than the corresponding values in the previous row. It is pretty...
2
by: Daniel Walzenbach | last post by:
Hi, I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to...
13
by: pmcguire | last post by:
I have a DataGrid control for which I have also created several new extended DataGridColumnStyles. They behave pretty nicely, but I can't figure out how to implement Selected Item formatting for...
14
by: Jack Kaufmann | last post by:
I am trying to verify a datagrid in which there must be an entry in both columns of any new row, and those values must be greater than the corresponding values in the previous row. It is pretty...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.