SelectionList.SelectedIndexChanged イベントとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SelectionList.SelectedIndexChanged イベントの意味・解説 

SelectionList.SelectedIndexChanged イベント

ユーザーが SelectionList オブジェクト選択変更するたびに発生します

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

Public Event SelectedIndexChanged As
 EventHandler
Dim instance As SelectionList
Dim handler As EventHandler

AddHandler instance.SelectedIndexChanged, handler
public event EventHandler SelectedIndexChanged
/** @event */
public void add_SelectedIndexChanged (EventHandler
 value)

/** @event */
public void remove_SelectedIndexChanged (EventHandler
 value)
JScript では、イベント使用できますが、新規に宣言することはできません。
解説解説
使用例使用例

SelectedIndexChanged イベント使用する方法次のコード例示しますポストバック時に Rows プロパティ使用してリスト拡張する方法示してます。

メモメモ

次のコード サンプルはシングルファイル コード モデル使用しており、分離コード ファイル直接コピーされ場合正常に動作しない可能性あります。このコード サンプルは、拡張子.aspx の空のテキスト ファイルコピーする必要があります詳細については、「ASP.NET Web ページコード モデル」を参照してください

<%@ 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
            ' Create data for the list
            Dim arr As New
 ArrayList()
            arr.Add(New _
                Task("Verify transactions", "Done"))
            arr.Add(New _
                Task("Check balance sheet", "Scheduled"))
            arr.Add(New _
                Task("Call customer", "Done"))
            arr.Add(New _
                Task("Issue checks", "Pending"))
            arr.Add(New _
                Task("Send report", "Pending"))
            arr.Add(New _
                Task("Attend meeting", "Scheduled"))
            
            ' Set properties for the list
            SelList1.SelectType = _
                ListSelectType.ListBox
            SelList1.Wrapping = Wrapping.NoWrap
            SelList1.DataValueField = "Status"
            SelList1.DataTextField  = "TaskName"
            SelList1.Rows = 3

            ' Bind the list to the data
            SelList1.DataSource = arr
            SelList1.DataBind ()

            Label1.Text = "Select an item and click the button."
            Label2.Text = "Tasks are arranged by priority"
        End If
    End Sub
    
    Private Sub ShowStatus(ByVal
 sender As Object, ByVal
 e As EventArgs)
        Const statusSpec As String
 = "Status: {0} is {1}"
        Const prioSpec As String
 = "Priority: {0}"
        
        ' Expand the list to show all items
        SelList1.Rows = SelList1.Items.Count

        ' Display the status
        Label1.Text = String.Format(statusSpec, _
            SelList1.Selection.Text, _
            SelList1.Selection.Value)
        ' Display the priority
        Label2.Text = String.Format(prioSpec, _
            (SelList1.SelectedIndex + 1))
    End Sub

    ' Custom class for the task data
    Class Task
        Private _TaskName As String
        Private _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 xmlns="http:'www.w3.org/1999/xhtml" >
<body>
    <mobile:Form runat="server" id="Form1">
        <mobile:Label runat="server" id="Label1"
 />
        <mobile:Label runat="server" id="Label2"
 />
        <mobile:SelectionList runat="server" id="SelList1"
 
            OnSelectedIndexChanged="ShowStatus" />
        <mobile:Command ID="Command1" runat="server"
 
            Text="Show Status" />
    </mobile:Form>
</body>
</html>
<%@ 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)
        {
            // Create data for the list
            ArrayList arr = new ArrayList();
            arr.Add (new 
                Task ("Verify transactions", "Done"));
            arr.Add (new 
                Task ("Check balance sheet", "Scheduled"));
            arr.Add (new 
                Task ("Call customer",       "Done"));
            arr.Add (new 
                Task ("Issue checks",          "Pending"));
            arr.Add (new 
                Task ("Send report",         "Pending"));
            arr.Add (new 
                Task ("Attend meeting",      "Scheduled"));
            
            // Set properties for the list
            SelList1.SelectType = 
                ListSelectType.ListBox;
            SelList1.Wrapping = Wrapping.NoWrap;
            SelList1.DataValueField = "Status";
            SelList1.DataTextField  = "TaskName";
            SelList1.Rows = 3;

            // Bind the list to the data
            SelList1.DataSource = arr;
            SelList1.DataBind ();

            Label1.Text = "Select an item and click the button.";
            Label2.Text = "Tasks are arranged by priority";
        }
    }
    
    void ShowStatus(Object sender, EventArgs e)
    {
        string statusSpec = "Status: {0} is {1}";
        string prioSpec = "Priority: {0}";
        
        // Expand the list to show all items
        SelList1.Rows = SelList1.Items.Count;

        // Display the status
        Label1.Text = String.Format(statusSpec, 
            SelList1.Selection.Text,
            SelList1.Selection.Value);
        // Display the priority
        Label2.Text = String.Format(prioSpec, 
            (SelList1.SelectedIndex + 1));
    }

    // Custom class for the task data
    class Task
    {
        private String _TaskName;
        private String _Status;

        public Task(String TaskName, String Status)
        {
            _TaskName = TaskName;
            _Status = Status;
        }
        public String TaskName { get { return
 _TaskName; } }
        public String Status { get { return
 _Status; } }
    }
</script>

<html  >
<body>
    <mobile:Form runat="server" id="Form1">
        <mobile:Label runat="server" id="Label1" />
        <mobile:Label runat="server" id="Label2" />
        <mobile:SelectionList runat="server" id="SelList1"
 
            OnSelectedIndexChanged="ShowStatus" />
        <mobile:Command ID="Command1" runat="server" 
            Text="Show Status" />
    </mobile:Form>
</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SelectionList クラス
SelectionList メンバ
System.Web.UI.MobileControls 名前空間
OnSelectedIndexChanged
SelectionList.SelectedIndex プロパティ
その他の技術情報
ASP.NET でのデータ アクセス
SelectionList コントロール概要
新しコントロール作成
カスタム モバイル コントロール作成



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

辞書ショートカット

すべての辞書の索引

SelectionList.SelectedIndexChanged イベントのお隣キーワード
検索ランキング

   

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



SelectionList.SelectedIndexChanged イベントのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS