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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Get Row/Col of Negative Point

Thread ID:





31394 Jul 6,2005 08:53 PM UTC Jul 6,2005 10:19 PM UTC WinForms 1
Tags: GridControl
Asked On July 6, 2005 08:53 PM UTC

When scrolling the grid, it is possible to get a point with a negative y value when calling the RowColToPoint to method. For example, if I scroll the grid so that row 1 is no longer visible and call this.ViewLayout.RowColToPoint(1, 1, false), I get a point with a negative y value. How can I get the row col values with this point? When I call PointToRowCol(pt,out row, out col) with a point that has a negative y value, I get -1 as the row and column. What is the reverse of RowColToPoint that will work with a point that is off the grid? Thanks, Steve

Administrator [Syncfusion]
Replied On July 6, 2005 10:19 PM UTC

There is no grid method that does this, so you will have to write your own. Here is a rough try at it. You will probably have to tweak it. It starts at the top and moves down until it finds the right row. You coulf try using a bunary search instead of this linear search if performance is a problem for you.
private int GetRowAtNegY(int y)
	if(y >= 0 )
		return -1;
	int y0 = this.gridControl1.ViewLayout.RowColToPoint(1,1, GridCellSizeKind.ActualSize).Y;
	if(y0 >= 0)
		return -1;
	int i = 1;
	while(i < this.gridControl1.RowCount && y > y0 + this.gridControl1.RowHeights[i])
		y0 += this.gridControl1.RowHeights[i];
	return i;


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

or the page will be automatically redirected to 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