)
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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get the screen point for the given cell coordinates in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 19, 2019
Tags: cellposition

Screen point for particular cell in grid

To get the screen point of a particular cell in the GridControl, you can get the cell's rectangle from the RangeInfoToRectangle method. Then, with this rectangle's coordinates, you can get the screen point by using the PointToScreen method.

C#

//GridControl CellClick event triggered from designer to get notification on CellClick.
this.gridControl1.CellClick += new Syncfusion.Windows.Forms.Grid
                    .GridCellClickEventHandler(this.gridControl1_CellClick);
private void gridControl1_CellClick(object sender, Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs e)
{
//Accessing cell rectangle by using RangeInfoRectangle method.
    Rectangle rect = this.gridControl1.RangeInfoToRectangle
                   (GridRangeInfo.Cell(e.RowIndex,e.ColIndex));
    //Screen point calculated by using pointToScreen method.
    Point screenPoint = this.gridControl1.PointToScreen(new Point(rect.Left, rect.Top));
    //ScreenPoint displayed in the MessageBox.
    MessageBox.Show(screenPoint.ToString());
}

VB

'GridControl CellClick event triggered from designer for getting notification on CellClick.
AddHandler gridControl1.CellClick, AddressOf gridControl1_CellClick
Private Sub gridControl1_CellClick(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs) Handles gridControl1.CellClick
'Accessing cell rectangle by using RangeInfoRectangle method.
 Dim rect As Rectangle = Me.gridControl1.RangeInfoToRectangle(GridRangeInfo.Cell(e.RowIndex,e.ColIndex))
'Screen point calculated by using pointToScreen method.
 Dim screenPoint As Point = Me.gridControl1.PointToScreen(New Point(rect.Left, rect.Top))
.'ScreenPoint displayed in the MessageBox.
 MessageBox.Show(screenPoint.ToString())
End Sub

Screen point for a particular cell in the GridControl

Figure 1: Screen point for a particular cell in the GridControl

Samples:

C#: ScreenPoint-C#

VB: ScreenPoint-VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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