SiteMapNodeCollection コンストラクター

定義

SiteMapNodeCollection クラスの新しいインスタンスを初期化します。

オーバーロード

SiteMapNodeCollection()

SiteMapNodeCollection クラスの新しいインスタンスを初期化します。これが既定のインスタンスです。

SiteMapNodeCollection(Int32)

指定した初期量を使用して、SiteMapNodeCollection クラスの新しいインスタンスを初期化します。

SiteMapNodeCollection(SiteMapNode)

SiteMapNodeCollection クラスの新しいインスタンスを初期化して、SiteMapNode オブジェクトをコレクションの InnerList プロパティに追加します。

SiteMapNodeCollection(SiteMapNode[])

SiteMapNodeCollection クラスの新しいインスタンスを初期化して、SiteMapNode 型の配列をコレクションの InnerList プロパティに追加します。

SiteMapNodeCollection(SiteMapNodeCollection)

SiteMapNodeCollection クラスの新しいインスタンスを初期化して、指定した SiteMapNodeCollection コレクションのリスト項目をすべてコレクションの InnerList プロパティに追加します。

SiteMapNodeCollection()

SiteMapNodeCollection クラスの新しいインスタンスを初期化します。これが既定のインスタンスです。

public:
 SiteMapNodeCollection();
public SiteMapNodeCollection ();
Public Sub New ()

次のコード例では、 コンストラクターを SiteMapNodeCollection 使用して新しい SiteMapNodeCollection コレクションを作成し、 メソッドを使用して に要素を追加する SiteMapNodeCollection 方法を Add 示します。

// The LoadSiteMapData() method loads site navigation
// data from persistent storage into a DataTable.
DataTable siteMap = LoadSiteMapData();

// Create a SiteMapNodeCollection.
SiteMapNodeCollection nodes = new SiteMapNodeCollection();

// Create a SiteMapNode and add it to the collection.
SiteMapNode tempNode;
DataRow row;
int index = 0;

while (index < siteMap.Rows.Count)
{

    row = siteMap.Rows[index];

    // Create a node based on the data in the DataRow.
    tempNode = new SiteMapNode(SiteMap.Provider,
                                row["Key"].ToString(),
                                row["Url"].ToString());

    // Add the node to the collection.
    nodes.Add(tempNode);
    ++index;
}
' The LoadSiteMapData() Function loads site navigation
' data from persistent storage into a DataTable.

Dim siteMapData As DataTable
siteMapData = LoadSiteMapData()

' Create a SiteMapNodeCollection.
Dim nodes As New SiteMapNodeCollection()

' Create a SiteMapNode and add it to the collection.
Dim tempNode As SiteMapNode
Dim row As DataRow
Dim index As Integer
index = 0

While (index < siteMapData.Rows.Count)

    row = siteMapData.Rows(index)

    ' Create a node based on the data in the DataRow.
    tempNode = New SiteMapNode(SiteMap.Provider, row("Key").ToString(), row("Url").ToString())

    ' Add the node to the collection.
    nodes.Add(tempNode)
    index = index + 1
End While

注釈

コンストラクターを SiteMapNodeCollection 使用して空 SiteMapNodeCollection のコレクションを作成します。 、、または Insert メソッドを使用して、 SiteMapNodeCollection に要素をAddAddRange追加できます。

こちらもご覧ください

適用対象

SiteMapNodeCollection(Int32)

指定した初期量を使用して、SiteMapNodeCollection クラスの新しいインスタンスを初期化します。

public:
 SiteMapNodeCollection(int capacity);
public SiteMapNodeCollection (int capacity);
new System.Web.SiteMapNodeCollection : int -> System.Web.SiteMapNodeCollection
Public Sub New (capacity As Integer)

パラメーター

capacity
Int32

SiteMapNodeCollection の初期量。

注釈

コンストラクターを SiteMapNodeCollection 使用して、 SiteMapNodeCollection 指定された初期容量を持つコレクションを作成します。

こちらもご覧ください

適用対象

SiteMapNodeCollection(SiteMapNode)

SiteMapNodeCollection クラスの新しいインスタンスを初期化して、SiteMapNode オブジェクトをコレクションの InnerList プロパティに追加します。

public:
 SiteMapNodeCollection(System::Web::SiteMapNode ^ value);
public SiteMapNodeCollection (System.Web.SiteMapNode value);
new System.Web.SiteMapNodeCollection : System.Web.SiteMapNode -> System.Web.SiteMapNodeCollection
Public Sub New (value As SiteMapNode)

パラメーター

value
SiteMapNode

SiteMapNodeCollection に追加する SiteMapNode

例外

valuenullです。

次のコード例では、1 つの初期オブジェクトをSiteMapNodeCollection使用してコレクションを作成し、 メソッドを使用して オブジェクトの SiteMapNodeSiteMapNodeCollection追加する方法をAddRangeSiteMapNodeします。 個々SiteMapNodeのオブジェクトが読み取りSiteMapNodeCollection専用である場合でも、 を変更できます。


// Create a SiteMapNodeCollection with all the nodes
// from the first two hierarchical levels of the current
// site map.
SiteMapNodeCollection baseCollection =
    new SiteMapNodeCollection(SiteMap.RootNode);

SiteMapNodeCollection childCollection =
    SiteMap.RootNode.ChildNodes;

baseCollection.AddRange(childCollection);

Response.Write( "<BR>Derived SiteMapNodeCollection.<BR><HR><BR>");
foreach (SiteMapNode node in baseCollection) {
    Response.Write( node.Title + "<BR>");
}

' Create a SiteMapNodeCollection with all the nodes
' from the first two hierarchical levels of the current
' site map.
Dim baseCollection As SiteMapNodeCollection
baseCollection = New SiteMapNodeCollection(SiteMap.RootNode)

Dim childCollection As SiteMapNodeCollection = SiteMap.RootNode.ChildNodes

baseCollection.AddRange(childCollection)

Response.Write( "<BR>Derived SiteMapNodeCollection.<BR><HR><BR>")

For Each node In baseCollection
    Response.Write( node.Title + "<BR>")
Next

注釈

コンストラクターをSiteMapNodeCollection使用して、1 つの初期SiteMapNodeオブジェクトをSiteMapNodeCollection含むコレクションを作成します。 、、または Insert メソッドを使用して、 SiteMapNodeCollection に要素をAddAddRange追加できます。

こちらもご覧ください

適用対象

SiteMapNodeCollection(SiteMapNode[])

SiteMapNodeCollection クラスの新しいインスタンスを初期化して、SiteMapNode 型の配列をコレクションの InnerList プロパティに追加します。

public:
 SiteMapNodeCollection(cli::array <System::Web::SiteMapNode ^> ^ value);
public SiteMapNodeCollection (System.Web.SiteMapNode[] value);
new System.Web.SiteMapNodeCollection : System.Web.SiteMapNode[] -> System.Web.SiteMapNodeCollection
Public Sub New (value As SiteMapNode())

パラメーター

value
SiteMapNode[]

SiteMapNode に追加する SiteMapNodeCollection 型の配列。

例外

valuenullです。

注釈

コンストラクターのSiteMapNodeCollection使用は、 コンストラクターを呼び出し、 メソッドをSiteMapNodeCollection使用してコレクションAddRangeに要素をSiteMapNodeCollection追加することと同じです。

こちらもご覧ください

適用対象

SiteMapNodeCollection(SiteMapNodeCollection)

SiteMapNodeCollection クラスの新しいインスタンスを初期化して、指定した SiteMapNodeCollection コレクションのリスト項目をすべてコレクションの InnerList プロパティに追加します。

public:
 SiteMapNodeCollection(System::Web::SiteMapNodeCollection ^ value);
public SiteMapNodeCollection (System.Web.SiteMapNodeCollection value);
new System.Web.SiteMapNodeCollection : System.Web.SiteMapNodeCollection -> System.Web.SiteMapNodeCollection
Public Sub New (value As SiteMapNodeCollection)

パラメーター

value
SiteMapNodeCollection

現在の SiteMapNodeCollection に追加する SiteMapNode を格納している SiteMapNodeCollection

例外

valuenullです。

次のコード例では、別SiteMapNodeCollectionSiteMapNode オブジェクトをSiteMapNodeCollectionベースとして使用してコレクションを作成する方法を示します。 メソッドは SiteMapNode.GetAllNodes 読み取り専用 SiteMapNodeCollectionを返します。これは、 プロパティが を IsReadOnlytrueしたときに検出されます。 読み取り専用SiteMapNodeCollectionを使用して新しい SiteMapNodeCollection が作成され、 Add メソッドと Remove メソッドを正常に呼び出すことができます。

SiteMapNodeCollection siteNodes = SiteMap.RootNode.GetAllNodes();

if ( siteNodes.IsReadOnly ||
     siteNodes.IsFixedSize )
{
    Response.Write("Collection is read-only or has fixed size.<BR>");

    // Create a new, modifiable collection from the existing one.
    SiteMapNodeCollection modifiableCollection =
         new SiteMapNodeCollection(siteNodes);

    // The MoveNode example method moves a node from position one to
    // the last position in the collection.
    MoveNode(modifiableCollection);
}
else {
    MoveNode(siteNodes);
}

Dim siteNodes As SiteMapNodeCollection
siteNodes = SiteMap.RootNode.GetAllNodes()

If siteNodes.IsReadOnly Or siteNodes.IsFixedSize Then

    Response.Write("Collection is read-only or has fixed size.<BR>")

    ' Create a new, modifiable collection from the existing one.
    Dim modifiableCollection As SiteMapNodeCollection
    modifiableCollection = New SiteMapNodeCollection(siteNodes)

    ' The MoveNode example method moves a node from position one to
    ' the last position in the collection.
    MoveNode(modifiableCollection)
Else
    MoveNode(siteNodes)
End If

注釈

コンストラクターのSiteMapNodeCollection使用は、 コンストラクターを呼び出し、 メソッドをSiteMapNodeCollection使用してコレクションAddRangeに要素をSiteMapNodeCollection追加することと同じです。

適用対象