Click here to Skip to main content
15,889,842 members
Articles / Programming Languages / C#
Tip/Trick

Show cell value as tool tip for a Windows Form Grid

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
23 Aug 2011CPOL 19.5K   3  
How to show the cell value as a tool tip for a Windows Form Grid.

To show a tool tip, add an event handler for the CellToolTipTextNeeded event and add the code below (depending on your requirement):


C#
private void gridView1_CellToolTipTextNeeded(object sender, 
    DataGridViewCellToolTipTextNeededEventArgs e)
{
    if (e.ColumnIndex == 0)
        e.ToolTipText = "PrintPreview";
    else if (e.ColumnIndex == 1)
        e.ToolTipText = "Print";
    else if (e.ColumnIndex == 2)
        e.ToolTipText = "delete the file";
    else
        e.ToolTipText = string.Format("{0}", 
            gridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --