<bdo id='9PmYK'></bdo><ul id='9PmYK'></ul>
<legend id='9PmYK'><style id='9PmYK'><dir id='9PmYK'><q id='9PmYK'></q></dir></style></legend>
  1. <i id='9PmYK'><tr id='9PmYK'><dt id='9PmYK'><q id='9PmYK'><span id='9PmYK'><b id='9PmYK'><form id='9PmYK'><ins id='9PmYK'></ins><ul id='9PmYK'></ul><sub id='9PmYK'></sub></form><legend id='9PmYK'></legend><bdo id='9PmYK'><pre id='9PmYK'><center id='9PmYK'></center></pre></bdo></b><th id='9PmYK'></th></span></q></dt></tr></i><div id='9PmYK'><tfoot id='9PmYK'></tfoot><dl id='9PmYK'><fieldset id='9PmYK'></fieldset></dl></div>
    <tfoot id='9PmYK'></tfoot>

    <small id='9PmYK'></small><noframes id='9PmYK'>

    1. 如何上下移动listBox中的项目?

      How to move item in listBox up and down?(如何上下移动listBox中的项目?)

          <small id='fZZVW'></small><noframes id='fZZVW'>

            <tfoot id='fZZVW'></tfoot>
              <bdo id='fZZVW'></bdo><ul id='fZZVW'></ul>
            • <i id='fZZVW'><tr id='fZZVW'><dt id='fZZVW'><q id='fZZVW'><span id='fZZVW'><b id='fZZVW'><form id='fZZVW'><ins id='fZZVW'></ins><ul id='fZZVW'></ul><sub id='fZZVW'></sub></form><legend id='fZZVW'></legend><bdo id='fZZVW'><pre id='fZZVW'><center id='fZZVW'></center></pre></bdo></b><th id='fZZVW'></th></span></q></dt></tr></i><div id='fZZVW'><tfoot id='fZZVW'></tfoot><dl id='fZZVW'><fieldset id='fZZVW'></fieldset></dl></div>

              <legend id='fZZVW'><style id='fZZVW'><dir id='fZZVW'><q id='fZZVW'></q></dir></style></legend>
                  <tbody id='fZZVW'></tbody>
                本文介绍了如何上下移动listBox中的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个 listBox1 对象,它包含一些项目.我有一个按钮可以向上移动所选项目,另一个可以向下移动所选项目.这两个按钮的代码应该是什么?

                I have a listBox1 object and it contains some items. I have a button to move selected item up and another to move selected item down. What should the code be to the two buttons?

                推荐答案

                private void UpClick()
                {
                    // only if the first item isn't the current one
                    if(listBox1.ListIndex > 0)
                    {
                        // add a duplicate item up in the listbox
                        listBox1.AddItem(listBox1.Text, listBox1.ListIndex - 1);
                        // make it the current item
                        listBox1.ListIndex = (listBox1.ListIndex - 2);
                        // delete the old occurrence of this item
                        listBox1.RemoveItem(listBox1.ListIndex + 2);
                    }
                }
                
                private void DownClick()
                {
                   // only if the last item isn't the current one
                   if((listBox1.ListIndex != -1) && (listBox1.ListIndex < listBox1.ListCount - 1))
                   {
                      // add a duplicate item down in the listbox
                      listBox1.AddItem(listBox1.Text, listBox1.ListIndex + 2);
                      // make it the current item
                      listBox1.ListIndex = listBox1.ListIndex + 2;
                      // delete the old occurrence of this item
                      listBox1.RemoveItem(listBox1.ListIndex - 2);
                   }
                }
                

                这篇关于如何上下移动listBox中的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                Cannot remove items from ListBox(无法从列表框中删除项目)
                Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)

                1. <legend id='XYhj6'><style id='XYhj6'><dir id='XYhj6'><q id='XYhj6'></q></dir></style></legend>
                  <i id='XYhj6'><tr id='XYhj6'><dt id='XYhj6'><q id='XYhj6'><span id='XYhj6'><b id='XYhj6'><form id='XYhj6'><ins id='XYhj6'></ins><ul id='XYhj6'></ul><sub id='XYhj6'></sub></form><legend id='XYhj6'></legend><bdo id='XYhj6'><pre id='XYhj6'><center id='XYhj6'></center></pre></bdo></b><th id='XYhj6'></th></span></q></dt></tr></i><div id='XYhj6'><tfoot id='XYhj6'></tfoot><dl id='XYhj6'><fieldset id='XYhj6'></fieldset></dl></div>
                    <bdo id='XYhj6'></bdo><ul id='XYhj6'></ul>
                      <tbody id='XYhj6'></tbody>

                        • <tfoot id='XYhj6'></tfoot>
                        • <small id='XYhj6'></small><noframes id='XYhj6'>