SyncfusionExamples / how-to-change-the-image-in-gridimagecolumn-after-mouse-hover-in-winforms-datagrid

How to change the image in GridImageColumn after mouse hover in WinForms DataGrid (SfDataGrid)?

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to change the image in GridImageColumn after mouse hover in WinForms DataGrid (SfDataGrid)?

About the sample.

This sample illustrates that how to change the image in gridimagecolumn after mouse hover in winforms datagrid.

By default, the Tooltip for grid cells will be loaded with CellValue. To add image in tooltip, 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");
          }
    }
}

Image in tooltip

Requirements to run the demo

Visual Studio 2015 and above versions

About

How to change the image in GridImageColumn after mouse hover in WinForms DataGrid (SfDataGrid)?


Languages

Language:C# 100.0%