Category / Section
How to get the cell's information on mouse hovering in WinForms GridGroupingControl?
1 min read
Cell information
In order to get the cell’s information when hover the mouse on a cell, TableControlCellMouseHoverEnter event can be used and cell rectangle width and height of a cell can be retrieved RangeInfoToRectangle.
C#
this.gridGroupingControl1.TableControlCellMouseHoverEnter += gridGroupingControl1_TableControlCellMouseHoverEnter; void gridGroupingControl1_TableControlCellMouseHoverEnter(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellMouseEventArgs e) { Rectangle rectangle = new Rectangle(); e.TableControl.CurrentCell.MoveTo(e.Inner.RowIndex, e.Inner.ColIndex); GridCurrentCell currentCell= e.TableControl.CurrentCell; if (e.Inner.ColIndex > 0) { rectangle = e.TableControl.RangeInfoToRectangle(GridRangeInfo.Cell(e.Inner.RowIndex, e.Inner.ColIndex)); } if (currentCell.Renderer != null) { String text = "Table:" + e.TableControl.TableDescriptor.Name +"\n"+ "Col Index: " + e.Inner.ColIndex +"\n" + "cell bounds:" + rectangle + "\n" +"Cell Width:" + rectangle.Width +"\n" + "Cell Height:" + rectangle.Height +"\n" + "Col Text :" + currentCell.Renderer.ControlText"\n" +; GridTableControl tablecontrol = gridGroupingControl1.TableControl; tooltip1.SetToolTip(tablecontrol, text + "CellSize: " + cellSize); tooltip1.Active = true; } }
VB
tooltip1 = New ToolTip() AddHandler Me.gridGroupingControl1.TableControlCellMouseHoverEnter, AddressOf gridGroupingControl1_TableControlCellMouseHoverEnter Private Sub gridGroupingControl1_TableControlCellMouseHoverEnter(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellMouseEventArgs) Dim rectangle As New Rectangle() e.TableControl.CurrentCell.MoveTo(e.Inner.RowIndex, e.Inner.ColIndex) Dim currentCell As GridCurrentCell = e.TableControl.CurrentCell If e.Inner.ColIndex > 0 Then rectangle = Me.gridGroupingControl1.GetTableControl(e.TableControl.TableDescriptor.Name).RangeInfoToRectangle(GridRangeInfo.Cell(e.Inner.RowIndex, e.Inner.ColIndex)) End If If currentCell.Renderer IsNot Nothing Then Dim text As String = "Table:" & e.TableControl.TableDescriptor.Name & "Col Index: " & e.Inner.ColIndex & "cell bounds:" & rectangle & "Cell Width:" & rectangle.Width & "Cell Height:" & rectangle.Height & "Col Text :" & currentCell.Renderer.ControlText Dim tablecontrol As GridTableControl = gridGroupingControl1.TableControl tooltip1.SetToolTip(tablecontrol, text) tooltip1.Active = True End If End Sub
Screenshot
Samples: