DataGridViewCellToolTipTextNeededEventArgsとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridViewCellToolTipTextNeededEventArgsの意味・解説 

DataGridViewCellToolTipTextNeededEventArgs クラス

メモ : このクラスは、.NET Framework version 2.0 で新しく追加されたものです。

CellToolTipTextNeeded イベントのデータを提供します。

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

Public Class DataGridViewCellToolTipTextNeededEventArgs
    Inherits DataGridViewCellEventArgs
Dim instance As DataGridViewCellToolTipTextNeededEventArgs
public class DataGridViewCellToolTipTextNeededEventArgs
 : DataGridViewCellEventArgs
public ref class DataGridViewCellToolTipTextNeededEventArgs
 : public DataGridViewCellEventArgs
public class DataGridViewCellToolTipTextNeededEventArgs
 extends DataGridViewCellEventArgs
public class DataGridViewCellToolTipTextNeededEventArgs
 extends DataGridViewCellEventArgs
解説解説

CellToolTipTextNeeded イベントが発生するのは、DataGridView コントロールの DataSource プロパティが設定されているか、VirtualMode プロパティが true の場合のみです。

CellToolTipTextNeeded イベントを処理すると、コントロールの ShowCellToolTips プロパティ値が true の場合に、マウス ポインタがセルの上に配置されるたびに、ハンドラ内で指定したツールヒントのテキストが表示されます。CellToolTipTextNeeded イベントは、セルの現在の状態または値に基づいてツールヒントを表示する場合に便利です。

CellToolTipTextNeeded イベントは、プログラム上で、またはマウス ポインタがセルに入ったときに、DataGridViewCell.ToolTipText プロパティの値が取得された場合にも必ず発生します。

ColumnIndex プロパティと RowIndex プロパティを使用すると、セルの状態または値を特定でき、さらにこの情報を使用して、ToolTipText プロパティを設定できます。このプロパティは、セルの ToolTipText プロパティの値を使用して初期化されますが、イベントの値によってオーバーライドされます。

大量のデータを処理するときは、CellToolTipTextNeeded イベントを処理してください。この結果、複数のセルに対してセルの ToolTipText 値を設定することによるパフォーマンスの低下を防止できます。詳細については、「Windows フォーム DataGridView コントロールを拡張するための推奨される手順」を参照してください。

イベント処理の詳細については、「イベントの利用」を参照してください。

使用例使用例

DataGridView の表示されていないセルからの情報を ToolTipText に設定するコード例を次に示します。

Public Sub dataGridView1_CellToolTipTextNeeded(ByVal
 sender As Object, _
    ByVal e As DataGridViewCellToolTipTextNeededEventArgs)
 _
    Handles dataGridView1.CellToolTipTextNeeded

    Dim newLine As String
 = Environment.NewLine
    If e.RowIndex > -1 Then
        Dim dataGridViewRow1 As DataGridViewRow
 = _
        dataGridView1.Rows(e.RowIndex)

        ' Add the employee's ID to the ToolTipText.
        e.ToolTipText = String.Format("EmployeeID
 {0}: {1}", _
            dataGridViewRow1.Cells("EmployeeID").Value.ToString(),
 _
            newLine)

        ' Add the employee's name to the ToolTipText.
        e.ToolTipText += String.Format("{0}
 {1} {2} {3}", _
            dataGridViewRow1.Cells("TitleOfCourtesy").Value.ToString(),
 _
            dataGridViewRow1.Cells("FirstName").Value.ToString(),
 _
            dataGridViewRow1.Cells("LastName").Value.ToString(),
 _
            newLine)

        ' Add the employee's title to the ToolTipText.
        e.ToolTipText += String.Format("{0}{1}{2}",
 _
            dataGridViewRow1.Cells("Title").Value.ToString(),
 _
            newLine, newLine)

        ' Add the employee's contact information to the ToolTipText.
        e.ToolTipText += String.Format("{0}{1}{2},
 ", _
            dataGridViewRow1.Cells("Address").Value.ToString(),
 newLine, _
            dataGridViewRow1.Cells("City").Value.ToString())
        If Not String.IsNullOrEmpty(
 _
            dataGridViewRow1.Cells("Region").Value.ToString())

            e.ToolTipText += String.Format("{0},
 ", _
               dataGridViewRow1.Cells("Region").Value.ToString())
        End If
        e.ToolTipText += String.Format("{0},
 {1}{2}{3} EXT:{4}{5}{6}", _
            dataGridViewRow1.Cells("Country").Value.ToString(),
 _
            dataGridViewRow1.Cells("PostalCode").Value.ToString(),
 _
            newLine, _
            dataGridViewRow1.Cells("HomePhone").Value.ToString(),
 _
            dataGridViewRow1.Cells("Extension").Value.ToString(),
 _
            newLine, newLine)

        ' Add employee information to the ToolTipText.
        Dim HireDate As DateTime = _
            CType(dataGridViewRow1.Cells("HireDate").Value,
 DateTime)
        e.ToolTipText += _
            String.Format("Employee since:
 {0}/{1}/{2}{3}Manager: {4}", _
                HireDate.Month.ToString(), HireDate.Day.ToString(), _
                HireDate.Year.ToString(), newLine, _
                dataGridViewRow1.Cells("Manager").Value.ToString())
    End If
End Sub
void dataGridView1_CellToolTipTextNeeded(object sender,
    DataGridViewCellToolTipTextNeededEventArgs e)
{
    string newLine = Environment.NewLine;
    if (e.RowIndex > -1)
    {
        DataGridViewRow dataGridViewRow1 = dataGridView1.Rows[e.RowIndex];

        // Add the employee's ID to the ToolTipText.
        e.ToolTipText = String.Format("EmployeeID {0}:{1}",
            dataGridViewRow1.Cells["EmployeeID"].Value, newLine);

        // Add the employee's name to the ToolTipText.
        e.ToolTipText += String.Format("{0} {1} {2}{3}",
            dataGridViewRow1.Cells["TitleOfCourtesy"].Value.ToString()
,
            dataGridViewRow1.Cells["FirstName"].Value.ToString(),
            dataGridViewRow1.Cells["LastName"].Value.ToString(),
            newLine);

        // Add the employee's title to the ToolTipText.
        e.ToolTipText += String.Format("{0}{1}{2}",
            dataGridViewRow1.Cells["Title"].Value.ToString(),
            newLine, newLine);

        // Add the employee's contact information to the ToolTipText.
        e.ToolTipText += String.Format("{0}{1}{2}, ",
            dataGridViewRow1.Cells["Address"].Value.ToString(), newLine
,
            dataGridViewRow1.Cells["City"].Value.ToString());
        if (!String.IsNullOrEmpty(
            dataGridViewRow1.Cells["Region"].Value.ToString()))
        {
            e.ToolTipText += String.Format("{0}, ",
                dataGridViewRow1.Cells["Region"].Value.ToString());
        }
        e.ToolTipText += String.Format("{0}, {1}{2}{3} EXT:{4}{5}{6}",
            dataGridViewRow1.Cells["Country"].Value.ToString(),
            dataGridViewRow1.Cells["PostalCode"].Value.ToString(),
            newLine, dataGridViewRow1.Cells["HomePhone"].Value.ToString()
,
            dataGridViewRow1.Cells["Extension"].Value.ToString(),
            newLine, newLine);

        // Add employee information to the ToolTipText.
        DateTime HireDate =
            (DateTime)dataGridViewRow1.Cells["HireDate"].Value;
        e.ToolTipText +=
            String.Format("Employee since: {0}/{1}/{2}{3}Manager: {4}"
,
            HireDate.Month.ToString(), HireDate.Day.ToString(),
            HireDate.Year.ToString(), newLine,
            dataGridViewRow1.Cells["Manager"].Value.ToString());
    }
}
継承階層継承階層
System.Object
   System.EventArgs
     System.Windows.Forms.DataGridViewCellEventArgs
      System.Windows.Forms.DataGridViewCellToolTipTextNeededEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewCellToolTipTextNeededEventArgs メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellToolTipTextNeeded イベント
DataGridView.DataSource プロパティ
DataGridView.VirtualMode プロパティ
DataGridView.ShowCellToolTips プロパティ
DataGridView.OnCellToolTipTextNeeded
DataGridViewCellToolTipTextNeededEventHandler
DataGridViewCellToolTipTextNeededEventArgs.ToolTipText
DataGridViewCell.ToolTipText プロパティ
その他の技術情報
Windows フォーム DataGridView コントロールを拡張するための推奨される手順

DataGridViewCellToolTipTextNeededEventArgs プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ ColumnIndex  イベントが発生したセルの列インデックスを示す値を取得します。 ( DataGridViewCellEventArgs から継承されます。)
パブリック プロパティ RowIndex  イベントが発生したセルの行インデックスを示す値を取得します。 ( DataGridViewCellEventArgs から継承されます。)
パブリック プロパティ ToolTipText ツールヒントのテキストを取得または設定します。
参照参照

関連項目

DataGridViewCellToolTipTextNeededEventArgs クラス
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellToolTipTextNeeded イベント
DataGridView.DataSource プロパティ
DataGridView.VirtualMode プロパティ
DataGridView.ShowCellToolTips プロパティ
DataGridView.OnCellToolTipTextNeeded
DataGridViewCellToolTipTextNeededEventHandler
DataGridViewCellToolTipTextNeededEventArgs.ToolTipText
DataGridViewCell.ToolTipText プロパティ

その他の技術情報

Windows フォーム DataGridView コントロールを拡張するための推奨される手順

DataGridViewCellToolTipTextNeededEventArgs メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DataGridViewCellToolTipTextNeededEventArgs クラス
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellToolTipTextNeeded イベント
DataGridView.DataSource プロパティ
DataGridView.VirtualMode プロパティ
DataGridView.ShowCellToolTips プロパティ
DataGridView.OnCellToolTipTextNeeded
DataGridViewCellToolTipTextNeededEventHandler
DataGridViewCellToolTipTextNeededEventArgs.ToolTipText
DataGridViewCell.ToolTipText プロパティ

その他の技術情報

Windows フォーム DataGridView コントロールを拡張するための推奨される手順

DataGridViewCellToolTipTextNeededEventArgs メンバ

CellToolTipTextNeeded イベントのデータを提供します。

DataGridViewCellToolTipTextNeededEventArgs データ型で公開されるメンバを以下の表に示します。


パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ ColumnIndex  イベントが発生したセルの列インデックスを示す値を取得します。(DataGridViewCellEventArgs から継承されます。)
パブリック プロパティ RowIndex  イベントが発生したセルの行インデックスを示す値を取得します。(DataGridViewCellEventArgs から継承されます。)
パブリック プロパティ ToolTipText ツールヒントのテキストを取得または設定します。
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DataGridViewCellToolTipTextNeededEventArgs クラス
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellToolTipTextNeeded イベント
DataGridView.DataSource プロパティ
DataGridView.VirtualMode プロパティ
DataGridView.ShowCellToolTips プロパティ
DataGridView.OnCellToolTipTextNeeded
DataGridViewCellToolTipTextNeededEventHandler
DataGridViewCellToolTipTextNeededEventArgs.ToolTipText
DataGridViewCell.ToolTipText プロパティ

その他の技術情報

Windows フォーム DataGridView コントロールを拡張するための推奨される手順



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「DataGridViewCellToolTipTextNeededEventArgs」の関連用語

DataGridViewCellToolTipTextNeededEventArgsのお隣キーワード
検索ランキング

   

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



DataGridViewCellToolTipTextNeededEventArgsのページの著作権

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

©2026 GRAS Group, Inc.RSS