How to add ToolTips to Individual Cells in a Windows Forms DataGridView Control.

 
You can display additional information about cell or description of cell content to user with the help of tooltips.You can add ToolTips to Individual Cells.

You can also disable the display of cell-level ToolTips by setting the DataGridView.ShowCellToolTips property to false.

Example

In following example we will set the tooltips on the different cells of datagridview control. This example requires a DataGridView control named dataGridView1 that contains a column named ‘Reputation’ for displaying string values of asterisk (“*”) symbols(see above picture). We use the CellFormatting event of the DataGridView control for doing it.

First we will bind the DataGridView with data:

private void BindDataGrid()
        {
            dataGridView1.Rows.Add();
            dataGridView1.Rows[0].Cells[0].Value = 1;
            dataGridView1.Rows[0].Cells[1].Value = "Ankur";
            dataGridView1.Rows[0].Cells[2].Value = "*";
            dataGridView1.Rows.Add();
            dataGridView1.Rows[1].Cells[0].Value = 2;
            dataGridView1.Rows[1].Cells[1].Value = "John";
            dataGridView1.Rows[1].Cells[2].Value = "* *";
            dataGridView1.Rows.Add();
            dataGridView1.Rows[2].Cells[0].Value = 3;
            dataGridView1.Rows[2].Cells[1].Value = "Smith";
            dataGridView1.Rows[2].Cells[2].Value = "* * *";
        }

And now We will set the tooltips to every cell of ‘Reputation’ column.

    private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if ((e.ColumnIndex == dataGridView1.Columns[2].Index) && e.Value != null)
            {
                DataGridViewCell cell =
                    this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
                if (e.Value.Equals("*"))
                {
                    cell.ToolTipText = "Bronze";
                }
                else if (e.Value.Equals("* *"))
                {
                    cell.ToolTipText = "Silver";
                }
                else if (e.Value.Equals("* * *"))
                {
                    cell.ToolTipText = "Gold";
                }            
            }
        }