Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,028

HOME > .NET Framework > Forum > ASP.NET กับ ListBox อ่านแบบ Multiple การ Move Option จาก Left -> Right และ Right -> Left



 

ASP.NET กับ ListBox อ่านแบบ Multiple การ Move Option จาก Left -> Right และ Right -> Left

 



Topic : 066228

Guest




ASP.NET กับ ListBox อ่านแบบ Multiple การ Move Option จาก Left -> Right และ Right -> Left



Tag : .NET, C#







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-09-08 23:09:14 By : etf View : 1400 Reply : 1
 

 

No. 1

Guest


Code (C#)
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication16.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
        <HEAD>
                <title>WebForm1</title>
                <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
                <meta name="CODE_LANGUAGE" Content="C#">
                <meta name="vs_defaultClientScript" content="JavaScript">
                <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">           
        </HEAD>
        <body MS_POSITIONING="GridLayout">
                <form id="Form1" method="post" runat="server">
                        <asp:ListBox Runat="server" ID="ListBox1" SelectionMode="Multiple"></asp:ListBox>
                        <asp:Button Runat="server" ID="btnMoveRight" Text=" Move >> "></asp:Button>
                        <asp:Button Runat="server" ID="btnMoveLeft" Text=" Move << "></asp:Button>
                        <asp:ListBox Runat="server" ID="ListBox2" SelectionMode="Multiple"></asp:ListBox>
                </form>
        </body>
</HTML>


Code (C#)
                private void Page_Load(object sender, EventArgs e)
                {
                        if (!IsPostBack)
                        {
                                ListBox1.Items.Add("Java");
                                ListBox1.Items.Add("DOT NET");
                                ListBox1.Items.Add("PASCAL");
                        }
                }

                private void btnMoveRight_Click(object sender, System.EventArgs e)
                {
                        for(int i=ListBox1.Items.Count-1;i>=0;i--)
                        {
                                if (ListBox1.Items[i].Selected==true)
                                {
                                        ListBox2.Items.Add(ListBox1.Items[i]);
                                        ListItem li = ListBox1.Items[i];
                                        ListBox1.Items.Remove(li);
                                }
                        }
                }

                private void btnMoveLeft_Click(object sender, System.EventArgs e)
                {
                        for(int i=ListBox2.Items.Count-1;i>=0;i--)
                        {
                                if (ListBox2.Items[i].Selected==true)
                                {
                                        ListBox1.Items.Add(ListBox2.Items[i]);
                                        ListItem li = ListBox2.Items[i];
                                        ListBox2.Items.Remove(li);
                                }
                        }               
                }







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-08 23:10:02 By : กุ้ง
 








Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่