Articles in this section
Category / Section

How to show ToolTip with image and text in WinForms DataGrid (SfDataGrid)?

1 min read

By default, the Tooltip for grid cells will be loaded with CellValue text. To add image in tooltip with existing text, the ToolTipOpening event can be used. In that event, the ToolTipInfo for the items can be updated with image.

//Event subscription
this.sfDataGrid1.ToolTipOpening += SfDataGrid1_ToolTipOpening;
 
//Event customization
private void SfDataGrid1_ToolTipOpening(object sender, ToolTipOpeningEventArgs e)
{
    var record = e.Record as OrderInfo;
 
    e.ToolTipInfo.Items.AddRange(new ToolTipItem[] { toolTipItem1, toolTipItem2 });
 
    var recordIndex = this.sfDataGrid1.TableControl.ResolveToRowIndex(record);
 
    if (e.RowIndex == recordIndex)
    {
        if (record.CustomerID == "FRANS")
        {
          e.ToolTipInfo.Items[1].Text = "FRANS";                        
          e.ToolTipInfo.Items[0].Image = Image.FromFile(@"../../Images/FRANS.png");
          }
    }
}

 

Show image in tooltip

View sample in GitHub

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