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

  • 相关阅读:
    BZOJ1106[POI2007]立方体大作战tet
    BZOJ4407 于神之怒加强版
    BZOJ1103: [POI2007]大都市meg
    BZOJ3170: [Tjoi2013]松鼠聚会
    Luogu 2912 [USACO08OCT]牧场散步Pasture Walking
    BZOJ1251 序列终结者- splay
    BZOJ1699: [Usaco2007 Jan]Balanced Lineup排队
    BZOJ 1005[HNOI2008]明明的烦恼
    二叉树
    [CODEVS1130]数字反转
  • 原文地址:https://www.cnblogs.com/Dincat/p/13437416.html
Copyright © 2011-2022 走看看