zoukankan      html  css  js  c++  java
  • C# winform listBox中的项上下移动(转)

     

    C# winform listBox中的项上下移动

    分类: C# winform 876人阅读 评论(0) 收藏 举报

    //上移节点
            private void btnUP_Click(object sender, EventArgs e)
            {
                int lbxLength = this.listBoxMenu.Items.Count;//listbox的长度   
                int iselect = this.listBoxMenu.SelectedIndex;//listbox选择的索引   
                if (lbxLength > iselect && iselect>0)
                {
                    object oTempItem = this.listBoxMenu.SelectedItem;
                    this.listBoxMenu.Items.RemoveAt(iselect);
                    this.listBoxMenu.Items.Insert(iselect - 1, oTempItem);
                    this.listBoxMenu.SelectedIndex = iselect - 1;
                }   
            }
            //下移节点
            private void btnDown_Click(object sender, EventArgs e)
            {
                int lbxLength = this.listBoxMenu.Items.Count;//listbox的长度   
                int iselect = this.listBoxMenu.SelectedIndex;//listbox选择的索引   
                if (lbxLength > iselect && iselect<lbxLength-1)
                {
                    object oTempItem = this.listBoxMenu.SelectedItem;
                    this.listBoxMenu.Items.RemoveAt(iselect);
                    this.listBoxMenu.Items.Insert(iselect + 1, oTempItem);
                    this.listBoxMenu.SelectedIndex = iselect + 1;
                }   
            }

  • 相关阅读:
    css(上)
    前端基础
    并发编程,python的进程,与线程
    网络编程 套接字socket TCP UDP
    python 类的内置函数2
    python3大特征之多态
    python 类(object)的内置函数
    类 与 继承
    类 与 面向对象
    OOP >>> 封装
  • 原文地址:https://www.cnblogs.com/meimao5211/p/3346317.html
Copyright © 2011-2022 走看看