我发现这篇文章寻找每行设置工具提示的帮助。
我只想确认在VS2008 SP1中处理CellToolTipText事件对我有效。
对于那些你们谁是想知道如何在文本设置为从底层数据行的值,这可能是有用的:
private void myDGV_CellToolTipTextNeeded(object sender, DataGridViewCellToolTipTextNeededEventArgs e)
{
// This is used to set tooltiptext for individual cells in the grid.
if (e.ColumnIndex == 2) // I only want tooltips for the second column (0-based)
{
if (e.RowIndex >= 0) // When grid is initialized rowindex == 0
{
// e.ToolTipText = "this is a test."; // static example.
DataRowView drv = ((DataGridView)sender).Rows[e.RowIndex].DataBoundItem as DataRowView;
MyTableRowClass theRow = drv.Row as MyTableRowClass;
e.ToolTipText = theRow.Col1 + "\r\n" + theRow.Col2;
}
}
}
我知道这是一个老问题,但黑客工作,与周围的工具提示组件真正正确的答案?我们遇到与列/单元格工具提示未显示相同的问题。这看起来像DataGridView中的一个应该得到解决的错误。 – Yoopergeek 2010-01-27 14:31:13
@Yoopergeek我同意,这是一个错误。我被告知它已在Framework 3.0中修复,但由于安装程序的限制,我们无法升级。 – 2010-01-27 14:41:29
我使用3.5 ...还没有修复。 ;) – Yoopergeek 2010-01-27 14:55:56