zoukankan      html  css  js  c++  java
  • 按钮类型控件 选择类型控件

    <body>
        <form id="form1" runat="server">
        <div class="style1">
        
            <br />
            <br />
            <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
                SelectionMode="Multiple">
            </asp:ListBox>
            <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
            <asp:Button ID="btnDel" runat="server" Text="移除" />
            <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
                Width="100px"></asp:ListBox>
                </div>
        </form>
    </body><body>
        <form id="form1" runat="server">
        <div class="style1">
        
            <br />
            <br />
            <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
                SelectionMode="Multiple">
            </asp:ListBox>
            <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
            <asp:Button ID="btnDel" runat="server" Text="移除" />
            <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
                Width="100px"></asp:ListBox>
               
        </div>
        </form>
    </body><body>
        <form id="form1" runat="server">
        <div class="style1">
        
            <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
                SelectionMode="Multiple">
            </asp:ListBox>
            <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
            <asp:Button ID="btnDel" runat="server" Text="移除" />
            <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
                Width="100px"></asp:ListBox>
               
        </div>
        </form>
    </body><body>
        <form id="form1" runat="server">
        <div class="style1">
        
           
            <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
                SelectionMode="Multiple">
            </asp:ListBox>
            <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
            <asp:Button ID="btnDel" runat="server" Text="移除" />
            <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
                Width="100px"></asp:ListBox>
                  </div>
        </form>
    </body><body>
        <form id="form1" runat="server">
        <div class="style1">
        
            <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
                SelectionMode="Multiple">
            </asp:ListBox>
            <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
            <asp:Button ID="btnDel" runat="server" Text="移除" />
            <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
                Width="100px"></asp:ListBox>
          
        </div>
        </form>
    </body>


    后台:

    protected void Page_Load(object sender, EventArgs e)
        {
            AddUser();
    
        }
        private void AddUser()
        {
            lblist.Items.Add("11");
            lblist.Items.Add("22");
            lblist.Items.Add("33");
            lblist.Items.Add("44");
            lblist.Items.Add("55");
            lblist.Items.Add("66");
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            for (int i = 0; i <lblist.Items.Count; i++)
            {
                if (lblist.Items[i].Selected)
                {
                    ListItem li = lbStat.Items.FindByValue(lblist.Items[i].Text);
                    if (li == null)
                    {
                        lbStat.Items.Add(lblist.Items[i].Text);
                    }
                }
            }
            lblist.ClearSelection();//清除项目中的选中状态
        }
     protected void btnDel_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < lbStat.Items.Count; i++)
            {
                if (lbStat.Items[i].Selected)
                {
                    lbStat.Items.RemoveAt(i);
                }
                lblist.ClearSelection();
            }
        }
  • 相关阅读:
    struts2 DMI
    MFC添加背景图片
    c++ 副本构造器
    climits
    Qt中的qreal
    Http概述(一)
    重构学习-重构原则
    QDir的mkdir和mkpath区别
    Qt学习笔记网络(一)
    Qt5 新特性
  • 原文地址:https://www.cnblogs.com/qiushuixizhao/p/3310083.html
Copyright © 2011-2022 走看看