次の方法で共有


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

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

プログラムでツールヒントを設定する

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

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

    ' 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. SetToolTip コンポーネントの ToolTip メソッドを使用します。

    ' 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 のツールヒントのテキストを削除します。

こちらも参照ください