この記事では、行ごとのツールチップの設定に関するヘルプを探しています。
CellToolTipTextイベントの処理がVS2008SP1で機能することを確認したかっただけです。
テキストを基になるデータ行の値にどのように設定するのか疑問に思っている人にとって、これは役立つかもしれません。
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;
}
}
}