We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Find Grid Cell by X,Y at MouseDown event

Thread ID:





6509 Aug 14,2003 03:15 PM UTC Aug 14,2003 08:17 PM UTC WinForms 3
Tags: GridControl
Asked On August 14, 2003 03:15 PM UTC

How does one hittest for a cell using X,Y from grid_mousedown event? I thought GridRangeInfo.FromTlhw(y,x,0,0) would do, but, the GridRangeInfo object it returns has X as the Left and Y as the Top, not the actual cell row /column index. I Don't think I can use CellMouseDown event, because I'm trying to find for disabled, read-only cells. Haven't actually tried... however, I'd still be interested in knowing how to find acell based on grid's X,Y coordinates. Thanks Eric

Administrator [Syncfusion]
Replied On August 14, 2003 05:39 PM UTC

Is this what you needed?
Private Sub gridControl1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Sub gridControl1.MouseDown
        If e.Button = MouseButtons.Right Then
       		dim rowIndex, colIndex as Integer
		Me.gridControl1.PointToRowCol(New Point(e.X, e.Y), rowIndex, colIndex)
		Console.WriteLine(rowIndex.ToString() + "  " + colIndex.ToString())
        End If
End Sub

private void gridControl1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
	if(e.Button == MouseButtons.Right)
		int row, col;
		if(this.gridControl1.PointToRowCol(new Point(e.X, e.Y), out row, out col, -1))
			Console.WriteLine(row.ToString() + "  " + col.ToString())

Replied On August 14, 2003 07:47 PM UTC

Perfect... What is GridRangeInfo.FromTlhw(y,x,...) used for? Eric

Administrator [Syncfusion]
Replied On August 14, 2003 08:17 PM UTC

It is just a static method that takes top, left, height,width and returns a GridRangeInfo object based on these entires. The 'normal' GridRangeInfo.Cells static method takes top, left, bottom, right.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon