• <bdo id='m4XN4'></bdo><ul id='m4XN4'></ul>

      <tfoot id='m4XN4'></tfoot>

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

        如何删除列表框中的多个选定项?

        时间:2023-10-07
      3. <legend id='UQgyl'><style id='UQgyl'><dir id='UQgyl'><q id='UQgyl'></q></dir></style></legend>
            <tbody id='UQgyl'></tbody>

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

              <bdo id='UQgyl'></bdo><ul id='UQgyl'></ul>
                  <tfoot id='UQgyl'></tfoot>
                  <i id='UQgyl'><tr id='UQgyl'><dt id='UQgyl'><q id='UQgyl'><span id='UQgyl'><b id='UQgyl'><form id='UQgyl'><ins id='UQgyl'></ins><ul id='UQgyl'></ul><sub id='UQgyl'></sub></form><legend id='UQgyl'></legend><bdo id='UQgyl'><pre id='UQgyl'><center id='UQgyl'></center></pre></bdo></b><th id='UQgyl'></th></span></q></dt></tr></i><div id='UQgyl'><tfoot id='UQgyl'></tfoot><dl id='UQgyl'><fieldset id='UQgyl'></fieldset></dl></div>
                  本文介绍了如何删除列表框中的多个选定项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的窗体包含两个列表框.Listbox1 中包含一些项目,而 listbox2 为空.当我按下表单上的按钮时,应将 listbox1 中的多个选定项目从 Listbox1 中删除并复制到 Listbox2.

                  My windows form contains two listboxes. Listbox1 contains some items in it and listbox2 is empty. When I press a button on the form, then multiple selected items from listbox1 should be removed from Listbox1 and copied to Listbox2.

                  我在 listbox1.SelectedItems 上尝试了 foreach 循环,但它只从列表中删除了一项.

                  I tried with foreach loop on listbox1.SelectedItems but it removes only 1 item from list.

                  有人有解决方案或代码吗?

                  Anyone has solution or code for this?

                  推荐答案

                  您可以在一个循环中完成所有操作.您应该在 SelectedIndices 上使用简单的 for 并向后循环:

                  You could do all in a single loop. You should use a simple for and loop backwards on SelectedIndices:

                  private void button1_Click(object sender, EventArgs e) 
                  { 
                      for(int x = listBox1.SelectedIndices.Count - 1; x>= 0; x--)
                      { 
                          int idx = listBox1.SelectedIndices[x];
                          listBox2.Items.Add(listBox1.Items[idx]); 
                          listBox1.Items.RemoveAt(idx);
                      } 
                  } 
                  

                  这篇关于如何删除列表框中的多个选定项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:C# - 无法在 WinForms 的列表框中执行键值操作 下一篇:ListBox 上的项目显示为类名

                  相关文章

                1. <small id='suBMO'></small><noframes id='suBMO'>

                  <tfoot id='suBMO'></tfoot>

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