クリックして評価とフィードバックをお寄せください
MSDN
MSDN ライブラリ
.NET 開発
.NET Framework 3.5
.NET Framework 3.5
System.Windows.Forms 名前空間
ToolTip クラス
すべて縮小/すべて展開 すべて縮小
このページは次のバージョンについて記述しています。
Microsoft Visual Studio 2008/.NET Framework 3.5

その他のバージョンについては、以下の情報を参照してください。
.NET Framework クラス ライブラリ
ToolTip クラス

更新 : 2007 年 11 月

ユーザーがポインタをコントロール上に配置したときに、そのコントロールの目的の簡単な説明を表示する、小さい四角形のポップアップ ウィンドウを表します。

名前空間 :  System.Windows.Forms
アセンブリ :  System.Windows.Forms (System.Windows.Forms.dll 内)

Visual Basic (宣言)
Public Class ToolTip _
    Inherits Component _
    Implements IExtenderProvider
Visual Basic (使用法)
Dim instance As ToolTip
C#
public class ToolTip : Component, IExtenderProvider
Visual C++
public ref class ToolTip : public Component, 
    IExtenderProvider
J#
public class ToolTip extends Component implements IExtenderProvider
JScript
public class ToolTip extends Component implements IExtenderProvider

ToolTip クラスを使用すると、ユーザーがポインタをコントロール上に配置したときに、ユーザーにヒントを提示できます。ToolTip クラスは、通常、コントロールの本来の用途をユーザーに警告するために使用します。たとえば、名前を受け入れる TextBox コントロールには、コントロールに入力する名前の書式を指定するツールヒント テキストを指定できます。ヒントを提示するだけではなく、ToolTip クラスを使用して、実行時のステータス情報も提示できます。たとえば、ToolTip クラスを使用して、インターネットの接続ステータスを表示する PictureBox コントロール上にユーザーがポインタを移動したときに、接続速度と回線の品質に関するデータが表示されるようにできます。

ToolTip クラスは、すべてのコンテナで使用できます。コンテナを明示的に指定するには、ToolTip(IContainer) コンストラクタを使用します。通常、1 つの ToolTip コンポーネントを使用して、1 つのフォーム上にある複数のコントロールのツールヒントを作成します。ToolTip を作成したら、SetToolTip メソッドを個別に呼び出して、ツールヒントの表示テキストを各コントロールに関連付けます。これにより、ユーザーがポインタをコントロール上に配置すると、ツールヒントとそのテキストが表示されるようになります。同じコントロールについて SetToolTip を複数回呼び出すことにより、コントロールに関連付けられたテキストを変更できます。コントロールに関連付けられているテキストを取得するには、GetToolTip メソッドを使用します。ToolTip クラスのインスタンスに関連付けられているすべてのツール ヒント テキストを削除するには、RemoveAll メソッドを使用します。

メモ :

ツール ヒント テキストは、無効にされているコントロールに対しては表示されません。ShowAlways プロパティが true に設定されている場合を除き、コンテナがアクティブでないときには、ツールヒントは表示されません。

ToolTip クラスには、ツールヒントの既定の動作と外観を変更するために次のプロパティとメソッドが用意されています。

すべてのツールヒント テキストを無効にすることにより、アプリケーションで表示されないようにするには、Active プロパティを使用します。通常、ツールヒントはオペレーティング システムによって描画されますが、ToolTip の外観をカスタマイズするには、OwnerDraw プロパティを true に設定し、Draw イベントを処理します。

ToolTipTitle クラスは、System.ComponentModel..::.IExtenderProvider インターフェイスを実装しています。このインターフェイスには、CanExtend という単一のメソッドがあります。ツールヒントは、デザイン時に同じフォーム上のコントロールを拡張し、ToolTip プロパティを追加します。拡張プロバイダの詳細については、「拡張プロバイダ」を参照してください。

ToolTip クラスのインスタンスを作成し、それを作成した場所である Form に、このインスタンスを関連付けるコード例を次に示します。次に、このコードは AutoPopDelayInitialDelayReshowDelay の各遅延プロパティを初期化します。さらに、ToolTip クラスのインスタンスが ShowAlways プロパティを true に設定して、フォームがアクティブかどうかに関係なく、ツール ヒント テキストを常に表示できるようにします。最後に、ツール ヒント テキストをフォーム上の 2 つのコントロール Button および CheckBox に関連付けます。このコード例では、コード内で定義されたメソッドが、button1 という名前の Button コントロールおよび checkBox1 という名前の CheckBox コントロールを含む Form 内に配置されており、そのメソッドが Form のコンストラクタから呼び出される必要があります。

Visual Basic
' This example assumes that the Form_Load event handling method
' is connected to the Load event of the form.
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
   ' Create the ToolTip and associate with the Form container.
   Dim toolTip1 As New ToolTip()

   ' Set up the delays for the ToolTip.
   toolTip1.AutoPopDelay = 5000
   toolTip1.InitialDelay = 1000
   toolTip1.ReshowDelay = 500
   ' Force the ToolTip text to be displayed whether or not the form is active.
   toolTip1.ShowAlways = True

   ' Set up the ToolTip text for the Button and Checkbox.
   toolTip1.SetToolTip(Me.button1, "My button1")
   toolTip1.SetToolTip(Me.checkBox1, "My checkBox1")
End Sub
C#
      // This example assumes that the Form_Load event handling method
      // is connected to the Load event of the form.
      private void Form1_Load(object sender, System.EventArgs e)
      {
         // Create the ToolTip and associate with the Form container.
         ToolTip toolTip1 = new ToolTip();

         // Set up the delays for the ToolTip.
         toolTip1.AutoPopDelay = 5000;
         toolTip1.InitialDelay = 1000;
         toolTip1.ReshowDelay = 500;
         // Force the ToolTip text to be displayed whether or not the form is active.
         toolTip1.ShowAlways = true;
            
         // Set up the ToolTip text for the Button and Checkbox.
         toolTip1.SetToolTip(this.button1, "My button1");
         toolTip1.SetToolTip(this.checkBox1, "My checkBox1");
      }
Visual C++
// This example assumes that the Form_Load event handling method
// is connected to the Load event of the form.
void Form1_Load( Object^ sender, System::EventArgs^ e )
{
   // Create the ToolTip and associate with the Form container.
   ToolTip^ toolTip1 = gcnew ToolTip;

   // Set up the delays for the ToolTip.
   toolTip1->AutoPopDelay = 5000;
   toolTip1->InitialDelay = 1000;
   toolTip1->ReshowDelay = 500;
   // Force the ToolTip text to be displayed whether or not the form is active.
   toolTip1->ShowAlways = true;

   // Set up the ToolTip text for the Button and Checkbox.
   toolTip1->SetToolTip( this->button1, "My button1" );
   toolTip1->SetToolTip( this->checkBox1, "My checkBox1" );
}
J#
// This example assumes that the Form_Load event handling method
// is connected to the Load event of the form.
private void Form1_Load(Object sender, System.EventArgs e)
{
    // Create the ToolTip and associate with the Form container.
    ToolTip toolTip1 = new ToolTip();
    // Set up the delays for the ToolTip.
    toolTip1.set_AutoPopDelay(5000);
    toolTip1.set_InitialDelay(1000);
    toolTip1.set_ReshowDelay(500);
    // Force the ToolTip text to be displayed whether or not the form
    // is active.
    toolTip1.set_ShowAlways(true);
    // Set up the ToolTip text for the Button and Checkbox.
    toolTip1.SetToolTip(this.button1, "My button1");
    toolTip1.SetToolTip(this.checkBox1, "My checkBox1");
} //Form1_Load
System..::.Object
  System..::.MarshalByRefObject
    System.ComponentModel..::.Component
      System.Windows.Forms..::.ToolTip
この型のすべてのパブリック static (Visual Basic では Shared) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。

.NET Framework

サポート対象 : 3.5、3.0、2.0、1.1、1.0
コミュニティ コンテンツ   コミュニティ コンテンツとは
新しいコンテンツの追加 RSS  注釈
Processing
© 2009 Microsoft Corporation. All rights reserved. 使用条件 | 商標 | プライバシー
Page view tracker