Question

How to add comment to cell in DataGridView? I need to comment my values in the grid.

How to add comment to cell in DataGridView? I need to comment my values in grid

Was it helpful?

Solution

set ToolTipText property on either DataGridViewCell or DataGridViewColumn to whatever text you want.

OTHER TIPS

Each cell can have a tooltip by setting the .ToolTipText property of that cell. Something like this:

// Event for formatting cells when rendering the grid
void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
    // Some logic for determining which cell this is in the row
    if ((e.ColumnIndex == this.dataGridView1.Columns["SomeColumn"].Index))
    {
        // Get a reference to the cell
        DataGridViewCell cell = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];

        // Set the tooltip text
        cell.ToolTipText = "some text";
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top