DataGridViewCell.ToolTipText プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridViewCell.ToolTipText プロパティの意味・解説 

DataGridViewCell.ToolTipText プロパティ

メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。

このセルに関連付けられているツールヒント テキストを取得または設定します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Dim instance As DataGridViewCell
Dim value As String

value = instance.ToolTipText

instance.ToolTipText = value
public string ToolTipText { get;
 set; }
/** @property */
public String get_ToolTipText ()

/** @property */
public void set_ToolTipText (String value)
public function get ToolTipText
 () : String

public function set ToolTipText
 (value : String)

プロパティ値
セルに関連付けられたツールヒント テキスト。既定値は 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";
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewCell クラス
DataGridViewCell メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.ShowCellToolTips プロパティ
DataGridView.CellToolTipTextChanged イベント
DataGridView.CellToolTipTextNeeded イベント
DataGridView.DataSource プロパティ
DataGridView.VirtualMode プロパティ



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「DataGridViewCell.ToolTipText プロパティ」の関連用語

DataGridViewCell.ToolTipText プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataGridViewCell.ToolTipText プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS