C# Windows窗体应用程序:网格视图上的帮助文本
我正在使用DataGridView用C#开发一个Windows应用程序。如何添加帮助文本以在用户将鼠标悬停在列上时显示?使用DataGridView的C# Windows窗体应用程序:网格视图上的帮助文本,c#,.net,datagridview,C#,.net,Datagridview,我正在使用DataGridView用C#开发一个Windows应用程序。如何添加帮助文本以在用户将鼠标悬停在列上时显示?使用DataGridView的工具提示属性 一篇很好的文章是很好的。这就是你想要的。下面是示例代码 // Sets the ToolTip text for cells in the Rating column. void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEven
工具提示属性
一篇很好的文章是很好的。这就是你想要的。下面是示例代码
// Sets the ToolTip text for cells in the Rating column.
void dataGridView1_CellFormatting(object sender,
DataGridViewCellFormattingEventArgs e)
{
if ( (e.ColumnIndex == this.dataGridView1.Columns["Rating"].Index)
&& e.Value != null )
{
DataGridViewCell cell =
this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
if (e.Value.Equals("*"))
{
cell.ToolTipText = "very bad";
}
else if (e.Value.Equals("**"))
{
cell.ToolTipText = "bad";
}
else if (e.Value.Equals("***"))
{
cell.ToolTipText = "good";
}
else if (e.Value.Equals("****"))
{
cell.ToolTipText = "very good";
}
}
}