DataGridViewCell.ToolTipText プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As DataGridViewCell Dim value As String value = instance.ToolTipText instance.ToolTipText = value
/** @property */ public String get_ToolTipText () /** @property */ public void set_ToolTipText (String value)
セルに関連付けられたツールヒント テキスト。既定値は String.Empty です。

このプロパティの値は、プロパティ値が Empty でない場合、マウス ポインタがセルの上に配置されたときにセルのツールヒントとして表示されます。このプロパティの値が Empty の場合、セル表示で値が切り詰められていれば、セル値が格納されたツールヒントが表示されます。それ以外の場合は、セルにツールヒントは表示されません。DataGridView.ShowCellToolTips プロパティを false に設定して、ツールヒントが表示されないようにすることもできます。
DataGridView コントロールの DataSource プロパティが設定されている場合、または VirtualMode プロパティが true の場合、ToolTipText プロパティの値を取得すると、コントロールの CellToolTipTextNeeded イベントが発生し、イベント ハンドラに指定された DataGridViewCellToolTipTextNeededEventArgs.ToolTipText プロパティの値が返されます。イベントのハンドラがない場合、ToolTipText プロパティの値を取得すると、以前に指定された値、またはその既定値である Empty が返されます。
大量のデータを処理する場合、複数のセルにセルの ToolTipText 値を設定する際のパフォーマンス低下を回避するには、まず CellToolTipTextNeeded イベントの処理が有効です。詳細については、「Windows フォーム DataGridView コントロールを拡張するための推奨される手順」を参照してください。
このプロパティを変更すると、(存在すれば) そのセルを所有している DataGridView で CellToolTipTextChanged イベントが発生します。

CellFormatting イベントのイベント ハンドラ内で ToolTipText プロパティを設定する方法を次のコード例に示します。次のコード例は、「方法 : Windows フォーム DataGridView コントロールの各セルにツールヒントを追加する」で示されている例の一部です。
' Sets the ToolTip text for cells in the Rating column. Sub dataGridView1_CellFormatting(ByVal sender As Object, _ ByVal e As DataGridViewCellFormattingEventArgs) _ Handles dataGridView1.CellFormatting If e.ColumnIndex = Me.dataGridView1.Columns("Rating").Index _ AndAlso Not (e.Value Is Nothing) Then With Me.dataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex) If e.Value.Equals("*") Then .ToolTipText = "very bad" ElseIf e.Value.Equals("**") Then .ToolTipText = "bad" ElseIf e.Value.Equals("***") Then .ToolTipText = "good" ElseIf e.Value.Equals("****") Then .ToolTipText = "very good" End If End With End If End Sub 'dataGridView1_CellFormatting
// 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"; } } }
// 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 != nullptr ) { 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"; } } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDataGridViewCell.ToolTipText プロパティを検索する場合は、下記のリンクをクリックしてください。

- DataGridViewCell.ToolTipText プロパティのページへのリンク