MobileListItemCollection 类

定义

注意

The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.

表示 MobileListItem 对象的集合,并用于存放 List 控件和 SelectionList 控件的项。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

public ref class MobileListItemCollection : System::Web::UI::MobileControls::ArrayListCollectionBase, System::Web::UI::IStateManager
public class MobileListItemCollection : System.Web.UI.MobileControls.ArrayListCollectionBase, System.Web.UI.IStateManager
[System.Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
public class MobileListItemCollection : System.Web.UI.MobileControls.ArrayListCollectionBase, System.Web.UI.IStateManager
type MobileListItemCollection = class
    inherit ArrayListCollectionBase
    interface IStateManager
[<System.Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")>]
type MobileListItemCollection = class
    inherit ArrayListCollectionBase
    interface IStateManager
Public Class MobileListItemCollection
Inherits ArrayListCollectionBase
Implements IStateManager
继承
MobileListItemCollection
属性
实现

示例

下面的代码示例演示如何通过 MobileListItemCollection 类操作 对象中的MobileListItem项。 该代码将所选项的索引用于 SelectionList.Items 属性。

<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    public void Page_Load(Object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Label1.Text = "Select an item";

            // Create and fill an array list.
            ArrayList listValues = new ArrayList();
            listValues.Add("One");
            listValues.Add("Two");
            listValues.Add("Three");

            // Bind the array to the list.
            SelList1.DataSource = listValues;
            SelList1.DataBind();

            // Set the SelectType.
            SelList1.SelectType =
                System.Web.UI.MobileControls.ListSelectType.Radio;
        }
        else
        {
            if (SelList1.SelectedIndex > -1)
            {
                // To show the selection, use the Selection property.
                Label1.Text = "Your selection is " +
                    SelList1.Selection;

                // Or, show the selection by using 
                // the MobileListItemCollection class.
                // Get the index of the selected item
                int idx = SelList1.SelectedIndex;
                Label2.Text = "You have selected " +
                    SelList1.Items[idx].Text;

                // Insert a copy of the selected item
                MobileListItem mi = SelList1.Selection;
                Label3.Text = "The index of your selection is " + 
                    mi.Index.ToString();
                SelList1.Items.Insert(idx, 
                    new MobileListItem(mi.Text + " Copy"));
            }
            else
            {
                Label1.Text = "No items selected";
            }
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:form id="form1" runat="server">
        <mobile:Label id="Label1" runat="server" 
            Text="Show a list" />
        <mobile:Label id="Label2" runat="server" />
        <mobile:Label id="Label3" runat="server" />
        <mobile:SelectionList runat="server" 
            id="SelList1" />
        <mobile:Command id="Command1" runat="server" 
            Text=" OK " />
    </mobile:form>
</body>
</html>
<%@ Page Language="VB" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        If Not IsPostBack Then
            Label1.Text = "Select an item"

            ' Create and fill an array list.
            Dim listValues As New ArrayList()
            listValues.Add("One")
            listValues.Add("Two")
            listValues.Add("Three")

            ' Bind the array to the list.
            SelList1.DataSource = listValues
            SelList1.DataBind()

            ' Set the SelectType.
            SelList1.SelectType = ListSelectType.Radio
        Else
            If (SelList1.SelectedIndex > -1) Then
                ' To show the selection, use the Selection property.
                Label1.Text = "Your selection is " & _
                    SelList1.Selection.Text

                ' Or, show the selection by using 
                ' the MobileListItemCollection class.
                ' Get the index of the selected item
                Dim idx As Integer = SelList1.SelectedIndex
                Label2.Text = "You have selected " & _
                    SelList1.Items(idx).Text

                ' Insert a copy of the selected item
                Dim mi As MobileListItem = SelList1.Selection
                Label3.Text = "The index of your selection is " & _
                    mi.Index.ToString()
                SelList1.Items.Insert(idx, _
                    New MobileListItem(mi.Text + " Copy"))
            Else
                Label1.Text = "No items selected"
            End If
        End If
    End Sub
</script>

<html xmlns="http:'www.w3.org/1999/xhtml" >
<body>
    <mobile:form id="form1" runat="server">
        <mobile:Label id="Label1" runat="server" 
            Text="Show a list" />
        <mobile:Label id="Label2" runat="server" />
        <mobile:Label id="Label3" runat="server" />
        <mobile:SelectionList runat="server" 
            id="SelList1" />
        <mobile:Command id="Command1" runat="server" 
            Text=" OK " />
    </mobile:form>
</body>
</html>

注解

访问 Items 控件的 List 属性或 Items 控件的 SelectionList 属性将 MobileListItemCollection 检索 对象。 可以在运行时在集合中添加或删除项。

对象 MobileListItemCollection 继承自 ICollection 接口。

构造函数

MobileListItemCollection()
已过时.

初始化 MobileListItemCollection 类的新实例。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

MobileListItemCollection(ArrayList)
已过时.

使用提供的数组初始化 MobileListItemCollection 类的新实例。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

属性

Count
已过时.

返回集合中元素的数目。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

(继承自 ArrayListCollectionBase)
IsReadOnly
已过时.

获取一个值,该值指示集合是否为只读。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

(继承自 ArrayListCollectionBase)
IsSynchronized
已过时.

获取一个值,该值指示集合是否已同步。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

(继承自 ArrayListCollectionBase)
IsTrackingViewState
已过时.

获取一个值,该值指示集合是否正在跟踪视图状态更改。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Item[Int32]
已过时.

通过索引获取集合中的 MobileListItem 项。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Items
已过时.

获取或设置数组列表对象中的项的集合。 默认值是 Empty。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

(继承自 ArrayListCollectionBase)
SyncRoot
已过时.

返回集合的 SyncRoot 对象。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

(继承自 ArrayListCollectionBase)

方法

Add(MobileListItem)
已过时.

将项添加到集合末尾。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Add(String)
已过时.

将项添加到集合的末尾,用提供的字符串作为 Text 属性。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Clear()
已过时.

清除集合。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Contains(MobileListItem)
已过时.

获取一个值,该值指示集合中是否包含给定的项。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

CopyTo(Array, Int32)
已过时.

从给定索引开始,将集合中的项复制到数组中。 仅供内部使用。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

(继承自 ArrayListCollectionBase)
Equals(Object)
已过时.

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

(继承自 Object)
GetAll()
已过时.

获取指定集合中的项,这些项的形式为 MobileListItem 对象的单个数组。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

GetEnumerator()
已过时.

检索该集合的枚举器。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

(继承自 ArrayListCollectionBase)
GetHashCode()
已过时.

作为默认哈希函数。

(继承自 Object)
GetType()
已过时.

获取当前实例的 Type

(继承自 Object)
IndexOf(MobileListItem)
已过时.

获取 MobileListItemCollection 对象中指定项的索引。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Insert(Int32, MobileListItem)
已过时.

将项添加到集合中的指定位置。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Insert(Int32, String)
已过时.

将项添加到集合中的指定位置。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

LoadViewState(Object)
已过时.

加载集合的以前保存的视图状态。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

MemberwiseClone()
已过时.

创建当前 Object 的浅表副本。

(继承自 Object)
Remove(MobileListItem)
已过时.

移除具有指定值的项。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

Remove(String)
已过时.

移除具有指定值的项。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

RemoveAt(Int32)
已过时.

删除指定索引处的项。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

SaveViewState()
已过时.

将服务器控件的视图状态更改保存到 Object。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

SetAll(MobileListItem[])
已过时.

MobileListItem 对象的数组设置为 MobileListItemCollection。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

ToString()
已过时.

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

(继承自 Object)
TrackViewState()
已过时.

指示集合跟踪其视图状态的更改。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

显式接口实现

IStateManager.IsTrackingViewState
已过时.

有关此成员的说明,请参见 IsTrackingViewState。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

IStateManager.LoadViewState(Object)
已过时.

有关此成员的说明,请参见 LoadViewState(Object)。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

IStateManager.SaveViewState()
已过时.

有关此成员的说明,请参见 SaveViewState()。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

IStateManager.TrackViewState()
已过时.

有关此成员的说明,请参见 TrackViewState()。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

扩展方法

Cast<TResult>(IEnumerable)
已过时.

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

OfType<TResult>(IEnumerable)
已过时.

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

AsParallel(IEnumerable)
已过时.

启用查询的并行化。

AsQueryable(IEnumerable)
已过时.

IEnumerable 转换为 IQueryable

适用于

另请参阅