TreeView.ShowPlusMinus プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As TreeView Dim value As Boolean value = instance.ShowPlusMinus instance.ShowPlusMinus = value
/** @property */ public boolean get_ShowPlusMinus () /** @property */ public void set_ShowPlusMinus (boolean value)
子ツリー ノードを含むツリー ノードの横にプラス記号ボタンとマイナス記号ボタンを表示する場合は true。それ以外の場合は false。既定値は true です。

ShowRootLines プロパティの値が true の場合に限り、ルート ツリー ノードの横にプラス記号ボタンとマイナス記号ボタンが表示されます。プラス記号ボタンとマイナス記号ボタンが表示されない場合、ツリー ノードに子ツリー ノードが含まれていることや、ツリー ノードが展開できることを視覚的に示す手段が他にはありません。この場合、ツリー ノードに子ツリー ノードが含まれているかどうか、展開または折りたたむことができるかどうかを確認するために、ユーザーはツリー ノードをダブルクリックする必要があります。

カスタマイズされた TreeView のコード例を次に示します。TreeView クラスを継承することにより、このカスタム バージョンには通常の TreeView の機能すべてが備わっています。ここでは、コンストラクタのさまざまなプロパティ値を変更して、固有の外観にします。ShowPlusMinus プロパティは false に設定されるため、このカスタム コントロールは、ノードがクリックされたときに展開または折りたたみが可能になるように、OnAfterSelect メソッドもオーバーライドします。
このようにしてカスタマイズしたコントロールは階層全体で使用できるため、一貫性のあるインターフェイスが簡単に作成できるようになります。プロジェクトごとにコントロールのさまざまなプロパティを指定する必要はありません。
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 'New 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 'OnAfterSelect End Class 'CustomizedTreeView
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 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 extends TreeView { public CustomizedTreeView() { // Customize the TreeView control by setting various properties. set_BackColor(System.Drawing.Color.get_CadetBlue()); set_FullRowSelect(true); set_HotTracking(true); set_Indent(34); set_ShowPlusMinus(false); // The ShowLines property must be false for the FullRowSelect // property to work. set_ShowLines(false); } //CustomizedTreeView protected 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.get_Action().Equals(TreeViewAction.Unknown))) { if (e.get_Node().get_IsExpanded()) { e.get_Node().Collapse(); } else { e.get_Node().Expand(); } } // Remove the selection. This allows the same node to be // clicked twice in succession to toggle the expansion state. set_SelectedNode(null); } //OnAfterSelect }//CustomizedTreeView

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からTreeView.ShowPlusMinus プロパティを検索する場合は、下記のリンクをクリックしてください。

- TreeView.ShowPlusMinus プロパティのページへのリンク