Articles in this section

How to show tooltip for Stacked Headers in WinForms DataGrid (SfDataGrid)?

WinForms DataGrid (SfDataGrid) doesn’t have direct support to show tooltip for the stacked header cell. However you can use SfToolTip to show tooltip for the stacked header cells by handling `SfDataGrid.TableControl.MouseMove` event.

public Form1()
{
    InitializeComponent();
 
    this.sfDataGrid1.TableControl.MouseMove += OnTableControl_MouseMove;
}
 
 
RowColumnIndex hoveredRowcolumnIndex = new RowColumnIndex(-1, -1);
SfToolTip Tooltip = new SfToolTip();
 
 
private void OnTableControl_MouseMove(object sender, MouseEventArgs e)
{
    var rowColumnIndex = this.sfDataGrid1.TableControl.PointToCellRowColumnIndex(e.Location, true);
    if (hoveredRowcolumnIndex != rowColumnIndex && rowColumnIndex.RowIndex == 0)
    {
        Tooltip.Hide();
        if (rowColumnIndex.ColumnIndex == 0)
            Tooltip.Show("StackedHeaderCell 1");
        if (rowColumnIndex.ColumnIndex == 1)
            Tooltip.Show("StackedHeaderCell 2");
    }
    else if (rowColumnIndex.RowIndex > 0)
        Tooltip.Hide();
    hoveredRowcolumnIndex = rowColumnIndex;
}

 

Showing tooltip for stacked headers

 

Take a moment to peruse the documentation, where you can find about StackedHeaders in SfDataGrid, with code examples.

You can download the example from GitHub

 

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