zoukankan      html  css  js  c++  java
  • 移动列表框项

    介绍 这个解决方案可

      

    以帮助解决一个小但有时令人恼火的问题,在处理大型项目时,这个问题可能会导致时间损失。它通过单击按钮向上和向下移动列表框项目。 使用的代码 首先,添加一个或两个按钮,取决于你想实现的,到你的表单,并设置这段代码的up按钮的行动: 隐藏,复制Code

    if (listBox1.SelectedItems.Count > 0)
    {
        object selected = listBox1.SelectedItem;
        int indx = listBox1.Items.IndexOf(selected);
        int totl = listBox1.Items.Count;
    
        if (indx == 0)
        {
            listBox1.Items.Remove(selected);
            listBox1.Items.Insert(totl - 1, selected);
            listBox1.SetSelected(totl - 1, true);
        }
        else{
            listBox1.Items.Remove(selected);
            listBox1.Items.Insert(indx - 1, selected);
            listBox1.SetSelected(indx - 1, true);
        }
    }

    然后,将这个添加到向下按钮操作: 隐藏,复制Code

    if (listBox1.SelectedItems.Count > 0)
    {
        object selected = listBox1.SelectedItem;
        int indx = listBox1.Items.IndexOf(selected);
        int totl = listBox1.Items.Count;
    
        if (indx == totl - 1)
        {
            listBox1.Items.Remove(selected);
            listBox1.Items.Insert(0, selected);
            listBox1.SetSelected(0, true);
        }
        else{
            listBox1.Items.Remove(selected);
            listBox1.Items.Insert(indx + 1, selected);
            listBox1.SetSelected(indx + 1, true);
        }
    }

    的兴趣点 为了更好的可用性,这些按钮可以在默认情况下禁用,也可以在项目被选中时启用。此外,我希望这段代码能派上用场! 本文转载于:http://www.diyabc.com/frontweb/news281.html

  • 相关阅读:
    arcgis server10.2自带打印模板路径
    【js笔记】数组那些事[0]
    微信打开网页不能下载的解决
    CSS里一个奇怪的属性
    存一些有用的CSS
    【JS笔记】闭包
    关于百度空间的关闭
    数据校验插件开发
    JavaScript 内存机制
    手写JQuery 的框架的实现
  • 原文地址:https://www.cnblogs.com/Dincat/p/13437416.html
Copyright © 2011-2022 走看看