set ToolTipText
property on either DataGridViewCell
or DataGridViewColumn
to whatever text you want.
How to add description to DataGridView Cell
-
30-06-2022 - |
문제
How to add comment to cell in DataGridView
? I need to comment my values in the grid.
해결책
다른 팁
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";
}
}
제휴하지 않습니다 StackOverflow