TreeView.HotTracking プロパティ

定義

ツリー ノードのラベル上にマウス ポインターが配置されたときに、そのラベルの外観がハイパーリンクになるかどうかを示す値を取得または設定します。

public:
 property bool HotTracking { bool get(); void set(bool value); };
public bool HotTracking { get; set; }
member this.HotTracking : bool with get, set
Public Property HotTracking As Boolean

プロパティ値

マウス ポインターが上に配置されたときに、ツリー ノードのラベルがハイパーリンクになる場合は true。それ以外の場合は false。 既定値は、false です。

次のコード例は、カスタマイズされた TreeViewを示しています。 クラスを TreeView 継承することで、このカスタム バージョンには一般的な TreeViewのすべての機能があります。 コンストラクターのさまざまなプロパティ値を変更すると、一意の外観が提供されます。 ShowPlusMinusプロパティは にfalse設定されているため、カスタマイズしたコントロールは メソッドをオーバーライドOnAfterSelectして、ノードをクリックしたときにノードを展開および折りたたむことができるようにします。

この方法でカスタマイズされたコントロールを組織全体で使用できるため、個々のプロジェクトでコントロール プロパティを指定しなくても、一貫性のあるインターフェイスを簡単に提供できます。

public ref class CustomizedTreeView: public TreeView
{
public:
   CustomizedTreeView()
   {

      // Customize the TreeView control by setting various properties.
      BackColor = System::Drawing::Color::CadetBlue;
      FullRowSelect = true;
      HotTracking = true;
      Indent = 34;
      ShowPlusMinus = false;

      // The ShowLines property must be false for the FullRowSelect
      // property to work.
      ShowLines = false;
   }

protected:
   virtual void OnAfterSelect( TreeViewEventArgs^ e ) override
   {
      // Confirm that the user initiated the selection.
      // This prevents the first node from expanding when it is
      // automatically selected during the initialization of
      // the TreeView control.
      if ( e->Action != TreeViewAction::Unknown )
      {
         if ( e->Node->IsExpanded )
         {
            e->Node->Collapse();
         }
         else
         {
            e->Node->Expand();
         }
      }

      
      // Remove the selection. This allows the same node to be
      // clicked twice in succession to toggle the expansion state.
      SelectedNode = nullptr;
   }
};
public class CustomizedTreeView : TreeView
{
    public CustomizedTreeView()
    {
        // Customize the TreeView control by setting various properties.
        BackColor = System.Drawing.Color.CadetBlue;
        FullRowSelect = true;
        HotTracking = true;
        Indent = 34;
        ShowPlusMinus = false;

        // The ShowLines property must be false for the FullRowSelect 
        // property to work.
        ShowLines = false;
    }

    protected override void OnAfterSelect(TreeViewEventArgs e)
    {
        // Confirm that the user initiated the selection.
        // This prevents the first node from expanding when it is
        // automatically selected during the initialization of 
        // the TreeView control.
        if (e.Action != TreeViewAction.Unknown)
        {
            if (e.Node.IsExpanded) 
            {
                e.Node.Collapse();
            }
            else 
            {
                e.Node.Expand();
            }
        }

        // Remove the selection. This allows the same node to be
        // clicked twice in succession to toggle the expansion state.
        SelectedNode = null;
    }
}
Public Class CustomizedTreeView
    Inherits TreeView

    Public Sub New()
        ' Customize the TreeView control by setting various properties.
        BackColor = System.Drawing.Color.CadetBlue
        FullRowSelect = True
        HotTracking = True
        Indent = 34
        ShowPlusMinus = False

        ' The ShowLines property must be false for the FullRowSelect 
        ' property to work.
        ShowLines = False
    End Sub


    Protected Overrides Sub OnAfterSelect(ByVal e As TreeViewEventArgs)
        ' Confirm that the user initiated the selection.
        ' This prevents the first node from expanding when it is
        ' automatically selected during the initialization of 
        ' the TreeView control.
        If e.Action <> TreeViewAction.Unknown Then
            If e.Node.IsExpanded Then
                e.Node.Collapse()
            Else
                e.Node.Expand()
            End If
        End If

        ' Remove the selection. This allows the same node to be
        ' clicked twice in succession to toggle the expansion state.
        SelectedNode = Nothing
    End Sub

End Class

注釈

プロパティが CheckBoxestrue設定されている場合、 HotTracking プロパティは無効です。

注意

プロパティが HotTrackingtrue設定されている場合、各ツリー ノード ラベルは、マウス ポインターがハイパーリンクの上を通過するときにハイパーリンクの外観を受け取ります。 Underlineフォント スタイルが にFont適用されForeColor、 が青に設定され、ラベルがリンクとして表示されます。 外観は、ユーザーのオペレーティング システムのインターネット設定によって制御されません。

適用対象