TreeView.FullRowSelect プロパティ

定義

選択されている項目を強調表示するときに、ツリー ビュー コントロールの幅全体を強調表示するかどうかを示す値を取得または設定します。

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

プロパティ値

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

注釈

この場合 FullRowSelect 、選択の強調表示は trueツリー ビューの幅全体にまたがり、ツリー ノード ラベルの幅ではなく表示されます。 にFullRowSelect設定trueされている場合ShowLines、プロパティは無視されます。

適用対象