List クラスとは? わかりやすく解説

List クラス

静的表示または対話操作可能なリストとして、項目のリスト描画ます。

名前空間: System.Web.UI.MobileControls
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)
構文構文

Public Class List
    Inherits PagedControl
    Implements INamingContainer, ITemplateable, IPostBackEventHandler
public class List : PagedControl, INamingContainer,
 ITemplateable, IPostBackEventHandler
public ref class List : public
 PagedControl, INamingContainer, ITemplateable, IPostBackEventHandler
public class List extends PagedControl implements
 INamingContainer, ITemplateable, 
    IPostBackEventHandler
public class List extends
 PagedControl implements INamingContainer, ITemplateable, 
    IPostBackEventHandler
解説解説
使用例使用例

配列使用して List オブジェクトバインドし、項目を格納するコード例次に示しますList オブジェクトの DataTextField プロパティと DataValueField プロパティプログラムによって設定できます

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

<script runat="server">
    ' Persist across multiple postbacks.
    Private Shared doneCount, schedCount, pendCount
 As Integer

    Protected Sub Page_Load(ByVal
 sender As Object, ByVal
 e As EventArgs)
        If Not IsPostBack Then
            ' Set the DataMembers of the List
            List1.DataValueField = "Status"
            List1.DataTextField = "TaskName"

            ' Create an ArrayList of task data
            Dim arr As ArrayList = New
 ArrayList()
            arr.Add(New Task("Define transactions",
 "scheduled"))
            arr.Add(New Task("Verify transactions",
 "scheduled"))
            arr.Add(New Task("Check balance
 sheet", "scheduled"))
            arr.Add(New Task("Compile balance
 sheet", "scheduled"))
            arr.Add(New Task("Prepare report",
 "scheduled"))
            arr.Add(New Task("Send report",
 "scheduled"))
            
            ' Bind the array to the list
            List1.DataSource = arr
            List1.DataBind()

            Const spec As String
 = "Start: {0} tasks are done, {1} " & _
               "tasks are scheduled, and {2} tasks are pending."
            Label2.Text = String.Format(spec, doneCount, _
                schedCount, pendCount)

            List1.Decoration = ListDecoration.Bulleted
        End If
    End Sub

    Private Sub Status_ItemCommand(ByVal
 sender As Object, _
        ByVal e As ListCommandEventArgs)

        Const spec As String
 = "You now have {0} tasks done, {1} " & _
            "tasks scheduled, and {2} tasks pending."

        ' Move selection to next status toward 'done'
        Select Case e.ListItem.Value
            Case "scheduled"
                schedCount -= 1
                pendCount += 1
                e.ListItem.Value = "pending"
            Case "pending"
                pendCount -= 1
                doneCount += 1
                e.ListItem.Value = "done"
                
        End Select

        ' Show the status of the current task
        Label1.Text = e.ListItem.Text & " is "
 & _
            e.ListItem.Value

        ' Show current selection counts
        Label2.Text = String.Format(spec, doneCount, _
            schedCount, pendCount)
    End Sub

    Private Sub Status_DataBinding(ByVal
 sender As Object, _
        ByVal e As ListDataBindEventArgs)

        ' Increment initial counts
        Select Case e.ListItem.Value
            Case "done"
                doneCount += 1
            Case "scheduled"
                schedCount += 1
            Case "pending"
                pendCount += 1
        End Select
    End Sub
    
    ' Custom class for the ArrayList items
    Private Class Task
        Private _TaskName, _Status As String
        
        Public Sub New(ByVal
 TaskName As String, _
            ByVal Status As String)

            _TaskName = TaskName
            _Status = Status
        End Sub
        Public ReadOnly Property
 TaskName() As String
            Get
                Return _TaskName
            End Get
        End Property
        Public ReadOnly Property
 Status() As String
            Get
                Return _Status
            End Get
        End Property
    End Class
</script>

<html  >
<body>
    <mobile:form id="form1" runat="server">
        <mobile:Label ID="Label3" Runat="server">
            Click a task to change its status from 
            scheduled to pending or from pending
 to done:
        </mobile:Label>
        <mobile:List runat="server" id="List1"
 
            OnItemCommand="Status_ItemCommand" 
            OnItemDataBind="Status_DataBinding" />
        <mobile:Label runat="server" id="Label1"
 
            ForeColor="green" Font-Italic="true"
 />
        <mobile:Label id="Label2" runat="server"
 />
    </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">
    ' Persist across multiple postbacks.
    Private Shared doneCount, schedCount, pendCount As Integer

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        If Not IsPostBack Then
            ' Set the DataMembers of the List
            List1.DataValueField = "Status"
            List1.DataTextField = "TaskName"

            ' Create an ArrayList of task data
            Dim arr As ArrayList = New ArrayList()
            arr.Add(New Task("Define transactions", "scheduled"))
            arr.Add(New Task("Verify transactions", "scheduled"))
            arr.Add(New Task("Check balance sheet", "scheduled"))
            arr.Add(New Task("Compile balance sheet", "scheduled"))
            arr.Add(New Task("Prepare report", "scheduled"))
            arr.Add(New Task("Send report", "scheduled"))
            
            ' Bind the array to the list
            List1.DataSource = arr
            List1.DataBind()

            Const spec As String = "Start: {0} tasks are done, {1} " &
 _
               "tasks are scheduled, and {2} tasks are pending."
            Label2.Text = String.Format(spec, doneCount, _
                schedCount, pendCount)

            List1.Decoration = ListDecoration.Bulleted
        End If
    End Sub

    Private Sub Status_DataBinding(ByVal sender As Object, _
        ByVal e As ListDataBindEventArgs)

        ' Increment initial counts
        Select Case e.ListItem.Value
            Case "done"
                doneCount += 1
            Case "scheduled"
                schedCount += 1
            Case "pending"
                pendCount += 1
        End Select
    End Sub

    Private Sub Status_ItemCommand(ByVal sender As Object, _
        ByVal e As ListCommandEventArgs)

        Const spec As String = "You now have {0} tasks done, {1} " &
 _
            "tasks scheduled, and {2} tasks pending."

        ' Move selection to next status toward 'done'
        Select Case e.ListItem.Value
            Case "scheduled"
                schedCount -= 1
                pendCount += 1
                e.ListItem.Value = "pending"
            Case "pending"
                pendCount -= 1
                doneCount += 1
                e.ListItem.Value = "done"
                
        End Select

        ' Show the status of the current task
        Label1.Text = e.ListItem.Text & " is " & _
            e.ListItem.Value

        ' Show current selection counts
        Label2.Text = String.Format(spec, doneCount, _
            schedCount, pendCount)
    End Sub

    ' Custom class for the ArrayList items
    Private Class Task
        Private _TaskName, _Status As String
        
        Public Sub New(ByVal TaskName As String, _
            ByVal Status As String)

            _TaskName = TaskName
            _Status = Status
        End Sub
        Public ReadOnly Property TaskName() As String
            Get
                Return _TaskName
            End Get
        End Property
        Public ReadOnly Property Status() As String
            Get
                Return _Status
            End Get
        End Property
    End Class
</script>

<html  >
<body>
    <mobile:form id="form1" runat="server">
        <mobile:Label ID="Label3" Runat="server">
            Click a task to change its status from 
            scheduled to pending or from pending to done:
        </mobile:Label>
        <mobile:List runat="server" id="List1" 
            OnItemCommand="Status_ItemCommand" 
            OnItemDataBind="Status_DataBinding" />
        <mobile:Label runat="server" id="Label1" 
            ForeColor="green" Font-Italic="true"
 />
        <mobile:Label id="Label2" runat="server" />
    </mobile:form>
</body>
</html>
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.Control
     System.Web.UI.MobileControls.MobileControl
       System.Web.UI.MobileControls.PagedControl
        System.Web.UI.MobileControls.List
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「List クラス」の関連用語

List クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



List クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS