Frage

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

War es hilfreich?

Lösung

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

Andere Tipps

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";
    }
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top