How to get cell's information in WinForms GridGroupingControl?
Cell information
In order to
get the cell’s information when hover the mouse on a cell in WinForms
GridGroupingControl, 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;
GridTableControl tableControl = gridGroupingControl1.TableControl;
tooltip1.SetToolTip(tableControl, text + "\nCellSize: " + cellSize);
tooltip1.Active = true;
}
}
VB
AddHandler Me.gridGroupingControl1.TableControlCellMouseHoverEnter, AddressOf gridGroupingControl1_TableControlCellMouseHoverEnter
Private Sub gridGroupingControl1_TableControlCellMouseHoverEnter(sender As Object, 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 = e.TableControl.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 & vbCrLf &
"Col Index: " & e.Inner.ColIndex & vbCrLf &
"Cell Bounds: " & rectangle.ToString() & vbCrLf &
"Cell Width: " & rectangle.Width & vbCrLf &
"Cell Height: " & rectangle.Height & vbCrLf &
"Col Text: " & currentCell.Renderer.ControlText
Dim tableControl As GridTableControl = gridGroupingControl1.TableControl
tooltip1.SetToolTip(tableControl, text & vbCrLf & "CellSize: " & cellSize)
tooltip1.Active = True
End If
End Sub
The screenshot below displays the cell information in GridGroupingControl.
Samples:
Conclusion
I hope you
enjoyed learning about how to get the cell's information on mouse hovering
in WinForms GridGroupingControl.
You can refer to our WinForms GridGroupingControl’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridGroupingControl documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms GridGroupingControl and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!