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

  • 相关阅读:
    JS可改变列宽table
    无图片,用css border实现尖三角
    IE6下position:fixed;兼容
    巧用cssText属性批量操作样式
    Java
    Java
    Java
    JRebel
    Spring
    ActiveMQ
  • 原文地址:https://www.cnblogs.com/Dincat/p/13437416.html
Copyright © 2011-2022 走看看