Articles in this section
Category / Section

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

1 min read

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

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied