The grid does not directly support tooltips, however you can use the Microsoft ToolTip component in order to display tooltips. In order to display tooltips in the grid, the SetToolTip method of the ToolTip component must be called with the desired text.
Demonstration
The following example demonstrates how to display a tooltip for each cell in the grid:
VB.NET |
Copy Code |
GridControl1.BeginInit()
GridControl1.DataSource = DataSet11 GridControl1.DataMember = "Orders"
' Subscribe to the MouseEnter event for each cell in the grid's DataRowTemplate. ' so that the content of each cell will be displayed when the mouse ' enters the cell
Dim cell As DataCell For Each cell In GridControl1.DataRowTemplate.Cells AddHandler cell.MouseEnter, AddressOf Me.ShowTip Next
GridControl1.EndInit()
Private Sub ShowTip( ByVal sender As Object, ByVal e As EventArgs ) ToolTip1.SetToolTip(GridControl1, CType(sender, DataCell).Value.ToString()) End Sub
|
C# |
Copy Code |
gridControl1.BeginInit();
gridControl1.DataSource = dataSet11; gridControl1.DataMember = "Orders";
// Subscribe to the MouseEnter event for each cell in the grid's DataRowTemplate. // so that the content of each cell will be displayed when the mouse // enters the cell foreach( DataCell cell in gridControl1.DataRowTemplate.Cells ) { cell.MouseEnter += new EventHandler( this.ShowTip ); }
gridControl1.EndInit();
private void ShowTip( object sender, EventArgs e ) { toolTip1.SetToolTip(gridControl1, ( ( DataCell )sender ).Value.ToString() ); }
|