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 プロパティ



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

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

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

   

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



DataGridViewCell.ToolTipText プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS