TreeView.ShowLines プロパティ
アセンブリ: System.Web (system.web.dll 内)

/** @property */ public boolean get_ShowLines () /** @property */ public void set_ShowLines (boolean value)
ノードを接続する線を表示する場合は true。それ以外の場合は false。既定値は false です。

ShowLines プロパティを使用して、子ノードを親ノードに接続する線を表示するかどうかを指定します。このプロパティが true に設定されている場合、TreeView コントロールは、LineImagesFolder プロパティによって指定された、Web からアクセス可能な線のイメージのフォルダを検索します。
![]() |
---|
LineImagesFolder プロパティが設定されていない場合、TreeView コントロールは、組み込みの既定イメージ (20 x 20 ピクセル) を使用します。 |

ShowLines プロパティを使用して、TreeView コントロールにノードを接続する線を表示する方法を次のコード例に示します。線のイメージのセットを作成して、サンプル アプリケーションのディレクトリ内にある LineImages という名前のフォルダに配置する場合は、線デザイナ ツールを使用してください。
<%@ Page Language="VB" %> <html> <body> <form runat="server"> <h3>TreeView LineImagesFolderUrl Example</h3> <asp:TreeView id="LinksTreeView" LineImagesFolder="~\LineImages" ShowLines="true" runat="server"> <Nodes> <asp:TreeNode Text="Table of Contents" SelectAction="None"> <asp:TreeNode Text="Chapter One"> <asp:TreeNode Text="Section 1.0"> <asp:TreeNode Text="Topic 1.0.1"/> <asp:TreeNode Text="Topic 1.0.2"/> <asp:TreeNode Text="Topic 1.0.3"/> </asp:TreeNode> <asp:TreeNode Text="Section 1.1"> <asp:TreeNode Text="Topic 1.1.1"/> <asp:TreeNode Text="Topic 1.1.2"/> <asp:TreeNode Text="Topic 1.1.3"/> <asp:TreeNode Text="Topic 1.1.4"/> </asp:TreeNode> </asp:TreeNode> <asp:TreeNode Text="Chapter Two"> <asp:TreeNode Text="Section 2.0"> <asp:TreeNode Text="Topic 2.0.1"/> <asp:TreeNode Text="Topic 2.0.2"/> </asp:TreeNode> </asp:TreeNode> </asp:TreeNode> <asp:TreeNode Text="Appendix A" /> <asp:TreeNode Text="Appendix B" /> <asp:TreeNode Text="Appendix C" /> </Nodes> </asp:TreeView> </form> </body> </html>
<%@ Page Language="C#" %> <html> <body> <form runat="server"> <h3>TreeView LineImagesFolderUrl Example</h3> <asp:TreeView id="LinksTreeView" LineImagesFolder="~\LineImages" ShowLines="true" runat="server"> <Nodes> <asp:TreeNode Text="Table of Contents" SelectAction="None"> <asp:TreeNode Text="Chapter One"> <asp:TreeNode Text="Section 1.0"> <asp:TreeNode Text="Topic 1.0.1"/> <asp:TreeNode Text="Topic 1.0.2"/> <asp:TreeNode Text="Topic 1.0.3"/> </asp:TreeNode> <asp:TreeNode Text="Section 1.1"> <asp:TreeNode Text="Topic 1.1.1"/> <asp:TreeNode Text="Topic 1.1.2"/> <asp:TreeNode Text="Topic 1.1.3"/> <asp:TreeNode Text="Topic 1.1.4"/> </asp:TreeNode> </asp:TreeNode> <asp:TreeNode Text="Chapter Two"> <asp:TreeNode Text="Section 2.0"> <asp:TreeNode Text="Topic 2.0.1"/> <asp:TreeNode Text="Topic 2.0.2"/> </asp:TreeNode> </asp:TreeNode> </asp:TreeNode> <asp:TreeNode Text="Appendix A" /> <asp:TreeNode Text="Appendix B" /> <asp:TreeNode Text="Appendix C" /> </Nodes> </asp:TreeView> </form> </body> </html>

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


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

/** @property */ public boolean get_ShowLines () /** @property */ public void set_ShowLines (boolean value)
ツリー ビュー コントロールのツリー ノード間を結ぶ線を描画する場合は true。それ以外の場合は false。既定値は 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.ShowLinesを検索する場合は、下記のリンクをクリックしてください。

- TreeView.ShowLinesのページへのリンク