Home Forums WinForms controls Xceed Grid for WinForms How to display tooltips

Viewing 1 post (of 1 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17809 |

    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.

    VB.NET

    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#

    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() );
    }

    Imported from legacy forums. Posted by Xceed admin (had 1290 views)

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.