zoukankan      html  css  js  c++  java
  • listbox 上下移动 (asp.net C#)

     protected void btnup_Click(object sender, EventArgs e)
        {

            if (lb_busspot.SelectedIndex == -1)
            {
                return;
            }

            //获得连续选中的项索引
            int[] Indices = lb_busspot.GetSelectedIndices();
            int length = Indices.Length;
            string text;
            string value;
            //如果选择的最小索引是0,表示是最上面的项
            if (Indices[0] == 0)
            {
                return;
            }

            //判断选择多项时是否是连续的项
            if (Indices.Length != 1 && Indices[0] + length - 1 != Indices[length - 1])
            {

                MessageBox.Show("Page", "请选择连续的项!");
                return;       
            }
            //将选中的上面一项未选中的值赋予临时变量
            text = lb_busspot.Items[Indices[0] - 1].Text;
            value = lb_busspot.Items[Indices[0] - 1].Value;

            for (int i = 0; i < length; i++)
            {
                lb_busspot.Items[Indices[i] - 1].Text = lb_busspot.Items[Indices[i]].Text;
                lb_busspot.Items[Indices[i] - 1].Value = lb_busspot.Items[Indices[i]].Value;
                //保证被选中状态
                lb_busspot.Items[Indices[i] - 1].Selected = true;
                lb_busspot.Items[Indices[i]].Selected = false;
            }
            //将选中的上面第一条未选中的值赋予到下面
            lb_busspot.Items[Indices[0] + length - 1].Text = text;
            lb_busspot.Items[Indices[0] + length - 1].Value = value;
        }

        protected void btndown_Click(object sender, EventArgs e)
        {
            if (lb_busspot.SelectedIndex==-1)
            {
                return;
            }
            //获得连续选中的项索引
            int[] Indices = lb_busspot.GetSelectedIndices();
            int length = Indices.Length;

            string text;
            string value;
            //如果选择的是最底下的项

            if (Indices[length-1]==lb_busspot.Items.Count-1)
            {
                return;
            }

            //判断选择多项时是否是连续的项

            if (Indices.Length !=1&&Indices[0]+length -1!=Indices[length -1])
            {
                MessageBox.Show("Page", "请选择连续的项!");
                return;
            }
            //将选中的下面一项未选中的值赋予临时变量
            text = lb_busspot.Items[Indices[length - 1] + 1].Text;
            value = lb_busspot.Items[Indices[length - 1] + 1].Value;
            for (int i = length; i > 0; i--)
            {
                lb_busspot.Items[Indices[i - 1] + 1].Text = lb_busspot.Items[Indices[i - 1]].Text;
                lb_busspot.Items[Indices[i - 1] + 1].Value = lb_busspot.Items[Indices[i - 1]].Value;
                lb_busspot.Items[Indices[i - 1] + 1].Selected = true;
                lb_busspot.Items[Indices[i - 1]].Selected = false;
            }
            //将下面第一条未选中的项的值赋予到上
            lb_busspot.Items[Indices[0]].Text = text;
            lb_busspot.Items[Indices[0]].Value = value;

        }

  • 相关阅读:
    购物商城实战
    Git(使用码云)
    Git(创建与合并分支)
    Git(工作区和暂存区概念)
    Git(删除文件)
    关于sqoop导入数据的时候添加--split-by配置项对sqoop的导入速度的影响。
    在hue当中设置hive当中数据库的控制权限。
    关于在hue当中执行定时任务,时间的设置。
    关于在hue当中调shell脚本oozie出现017: Could not lookup launched hadoop Job ID [job_1537350421540_0007] which was associated with action [0000003-180919174749982-oozie-oozi-W@shell-9865]. Failing this action!
    关于在在hue当中执行shell脚本使用oozie调度,一直出现laucher异常退出。
  • 原文地址:https://www.cnblogs.com/top5/p/1633541.html
Copyright © 2011-2022 走看看