次の方法で共有


方法: Windows フォーム上のコントロールのツールヒントをデザイン時に設定する

ToolTip の文字列は、コードまたは Visual Studio の Windows フォーム デザイナーで設定できます。 ToolTip コンポーネントについて詳しくは、「ToolTip コンポーネントの概要」を参照してください。

ツールヒントをプログラムによって設定する

  1. ツールヒントを表示するコントロールを追加します。

  2. ToolTip コンポーネントの SetToolTip メソッドを使用します。

    ' In this example, Button1 is the control to display the ToolTip.
    ToolTip1.SetToolTip(Button1, "Save changes")
    
    // In this example, button1 is the control to display the ToolTip.
    toolTip1.SetToolTip(button1, "Save changes");
    
    // In this example, button1 is the control to display the ToolTip.
    toolTip1->SetToolTip(button1, "Save changes");
    

ツールヒントをデザイナーで設定する

  1. Visual Studio で、ToolTip コンポーネントをフォームに追加します。

  2. ツールヒントを表示するコントロールを選択するか、フォームに追加します。

  3. [プロパティ] ウィンドウで、 [ToolTip1 の ToolTip] の値を適切なテキスト文字列に設定します。

ツールヒントをプログラムによって削除するには

  1. ToolTip コンポーネントの SetToolTip メソッドを使用します。

    ' In this example, Button1 is the control displaying the ToolTip.
    ToolTip1.SetToolTip(Button1, Nothing)
    
    // In this example, button1 is the control displaying the ToolTip.
    toolTip1.SetToolTip(button1, null);
    
    // In this example, button1 is the control displaying the ToolTip.
    toolTip1->SetToolTip(button1, NULL);
    

ツールヒントをデザイナーで削除する

  1. Visual Studio で、ツールヒントを表示しているコントロールを選択します。

  2. [プロパティ] ウィンドウで、 [ToolTip1 の ToolTip] のテキストを削除します。

関連項目