语言

WizardStepCollection 类

定义

表示作为向导的 WizardStepBase控件中派生对象的集合。 此类不能被继承。

public ref class WizardStepCollection sealed : System::Collections::IList
public sealed class WizardStepCollection : System.Collections.IList
type WizardStepCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public NotInheritable Class WizardStepCollection
Implements IList
继承
WizardStepCollection
实现

示例

以下示例演示如何使用声明性语法填充 WizardStepCollection 集合。

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
      <asp:Wizard id="Wizard1" 
        runat="server" >
        <WizardSteps>
          <asp:WizardStep id="Step1" 
            runat="server" 
            title="Step 1">
          </asp:WizardStep>
          <asp:WizardStep id="Step2" 
            runat="server" 
            title="Step 2">
          </asp:WizardStep>
          <asp:WizardStep id="Step3" 
            runat="server" 
            title="Step 3">
          </asp:WizardStep>
          <asp:WizardStep id="Step4" 
            runat="server" 
            title="Step 4">
          </asp:WizardStep>
          <asp:WizardStep id="Step5" 
            runat="server" 
            title="Step 5">
          </asp:WizardStep>
          <asp:WizardStep id="Step6" 
            runat="server" 
            title="Step 6">
          </asp:WizardStep>
        </WizardSteps>
        <HeaderTemplate>
          <b>WizardStepCollection Example</b>
        </HeaderTemplate>
      </asp:Wizard>
    </form>
  </body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
      <asp:Wizard id="Wizard1" 
        runat="server" >
        <WizardSteps>
          <asp:WizardStep id="Step1" 
            runat="server" 
            title="Step 1">
          </asp:WizardStep>
          <asp:WizardStep id="Step2" 
            runat="server" 
            title="Step 2">
          </asp:WizardStep>
          <asp:WizardStep id="Step3" 
            runat="server" 
            title="Step 3">
          </asp:WizardStep>
          <asp:WizardStep id="Step4" 
            runat="server" 
            title="Step 4">
          </asp:WizardStep>
          <asp:WizardStep id="Step5" 
            runat="server" 
            title="Step 5">
          </asp:WizardStep>
          <asp:WizardStep id="Step6" 
            runat="server" 
            title="Step 6">
          </asp:WizardStep>
        </WizardSteps>
        <HeaderTemplate>
          <b>WizardStepCollection Example</b>
        </HeaderTemplate>
      </asp:Wizard>
    </form>
  </body>
</html>

以下示例演示如何以编程方式填充 WizardStepCollection 集合。

<%@ Page Language="C#" CodeFile="WizardStepCollection.cs" Inherits="WizardStepCollectioncs_aspx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>WizardStepCollection Example</title>
</head>
<body>
    <form id="Form1" runat="server">
      <h3>WizardStepCollection Example</h3>
      <asp:PlaceHolder id="PlaceHolder1" 
        runat="server" />
    </form>
  </body>
</html>
<%@ Page Language="VB" CodeFile="WizardStepCollection.vb" Inherits="WizardStepCollectionvb_aspx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>WizardStepCollection Example</title>
</head>
<body>
    <form id="Form1" runat="server">
      <h3>WizardStepCollection Example</h3>
      <asp:PlaceHolder id="PlaceHolder1" 
        runat="server" />
    </form>
  </body>
</html>

下面是前面示例中网页的代码隐藏文件。

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class WizardStepCollectioncs_aspx : System.Web.UI.Page
{ 

    void Page_Load(object sender, EventArgs e)
    {
        // Programmatically create a wizard control.
        Wizard Wizard1 = new Wizard();

        // Create steps for the wizard control and insert them
        // into the WizardStepCollection collection.
        for (int i = 0; i <= 5; i++)
        {
            WizardStepBase newStep = new WizardStep();
            newStep.ID = "Step" + (i + 1).ToString();
            newStep.Title = "Step " + (i + 1).ToString();
            Wizard1.WizardSteps.Add(newStep);
        }

        // Display the wizard control on the Web page.
        PlaceHolder1.Controls.Add(Wizard1);
    }
}
Partial Class WizardStepCollectionvb_aspx
    Inherits System.Web.UI.Page

    Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        ' Programmatically create a wizard control.
        Dim Wizard1 As Wizard = New Wizard()

        ' Create steps for the wizard control and insert them
        ' into the WizardStepCollection collection.
        For i As Integer = 0 To 5
            Dim newStep As WizardStepBase = New WizardStep()
            newStep.ID = "Step" + (i + 1).ToString()
            newStep.Title = "Step " + (i + 1).ToString()
            Wizard1.WizardSteps.Add(newStep)
        Next

        ' Display the wizard control on the Web page.
        PlaceHolder1.Controls.Add(Wizard1)

    End Sub

End Class

注解

该 WizardStepCollection 类用于在充当向导的 WizardStepBase控件(如 CreateUserWizard 控件或 Wizard 控件)中存储和管理派生对象的集合。 例如,控件WizardWizardStepCollection将类用于其WizardSteps属性。

可通过多种方式访问 WizardStepBase以下项中的 WizardStepCollection派生对象:

属性

名称 说明
Count

获取控件WizardStepBase集合中的Wizard派生对象数WizardStepCollection。

IsReadOnly

获取一个值,该值指示是否可以 WizardStepBase修改集合中的派生对象。

IsSynchronized

获取一个值,该值指示是否同步对集合的访问(线程安全)。

Item[Int32]

WizardStepBase从集合中获取指定索引处的派生对象。

SyncRoot

获取一个对象,该对象可用于同步对集合的访问。

方法

名称 说明
Add(WizardStepBase)

将指定的 WizardStepBase派生对象追加到集合的末尾。

AddAt(Int32, WizardStepBase)

将指定的 WizardStepBase派生对象添加到集合中的指定索引位置。

Clear()

从集合中删除所有 WizardStepBase派生对象。

Contains(WizardStepBase)

确定集合是否 WizardStepCollection 包含特定的 WizardStepBase派生对象。

CopyTo(WizardStepBase[], Int32)

从 WizardStepCollection 集合中的所有项复制到兼容的一维对象数组 WizardStepBase ,从目标数组中的指定索引处开始。

Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetEnumerator()

返回一个 IEnumerator-implemented 对象,该对象可用于循环 WizardStepBase访问集合中的 -derived 对象。

GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type。

(继承自 Object)
IndexOf(WizardStepBase)

确定表示指定 WizardStepBase-derived 对象在集合中的位置的索引值。

Insert(Int32, WizardStepBase)

将指定的 WizardStepBase派生对象插入集合中的指定索引位置。

MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
Remove(WizardStepBase)

从集合中删除指定的 WizardStepBase派生对象。

RemoveAt(Int32)

从 WizardStepBase集合中移除位于指定位置的派生对象。

ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

显式接口实现

名称 说明
ICollection.CopyTo(Array, Int32)

从 WizardStepCollection 集合中的所有项复制到一维数组,从目标数组中的指定索引处开始。

IList.Add(Object)

将指定的对象追加到集合的末尾。

IList.Contains(Object)

确定集合是否包含指定的对象。

IList.IndexOf(Object)

确定表示指定对象在集合中的位置的索引值。

IList.Insert(Int32, Object)

将指定对象插入集合中的指定位置。

IList.IsFixedSize

获取一个值,该值指示集合是否具有固定大小。

IList.Item[Int32]

获取集合中指定索引处的对象。

IList.Remove(Object)

从集合中删除指定对象。

扩展方法

名称 说明
AsParallel(IEnumerable)

启用查询的并行化。

AsQueryable(IEnumerable)

将 IEnumerable 转换为 IQueryable。

Cast<TResult>(IEnumerable)

将 IEnumerable 的元素强制转换为指定类型。

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。

适用于

另请参阅