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.
Unfortunately, activation email could not send to your email. Please try again.

Find Grid Cell by X,Y at MouseDown event

Thread ID:

Created:

Updated:

Platform:

Replies:

6509 Aug 14,2003 11:15 AM Aug 14,2003 04:17 PM Windows Forms 3
loading
Tags: GridControl
ERobishaw
Asked On August 14, 2003 11:15 AM

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 01:39 PM

Is this what you needed?
'VB
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

//C#
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())
		}
	}
}

ERobishaw
Replied On August 14, 2003 03:47 PM

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

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

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.

CONFIRMATION

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.

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.

;