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

        <tfoot id='tTLnj'></tfoot>
      2. <small id='tTLnj'></small><noframes id='tTLnj'>

        <legend id='tTLnj'><style id='tTLnj'><dir id='tTLnj'><q id='tTLnj'></q></dir></style></legend>

        如何删除所有 ListBox 项目?

        时间:2023-10-07
        <i id='CQU9V'><tr id='CQU9V'><dt id='CQU9V'><q id='CQU9V'><span id='CQU9V'><b id='CQU9V'><form id='CQU9V'><ins id='CQU9V'></ins><ul id='CQU9V'></ul><sub id='CQU9V'></sub></form><legend id='CQU9V'></legend><bdo id='CQU9V'><pre id='CQU9V'><center id='CQU9V'></center></pre></bdo></b><th id='CQU9V'></th></span></q></dt></tr></i><div id='CQU9V'><tfoot id='CQU9V'></tfoot><dl id='CQU9V'><fieldset id='CQU9V'></fieldset></dl></div>
        <tfoot id='CQU9V'></tfoot>

            • <small id='CQU9V'></small><noframes id='CQU9V'>

              • <bdo id='CQU9V'></bdo><ul id='CQU9V'></ul>
                  <legend id='CQU9V'><style id='CQU9V'><dir id='CQU9V'><q id='CQU9V'></q></dir></style></legend>

                    <tbody id='CQU9V'></tbody>

                1. 本文介绍了如何删除所有 ListBox 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我创建了两个 RadioButton(重量和高度).我会在这两个类别之间切换.但它们共享相同的 ListBox 控制器(listBox1 和 listBox2).

                  I created two RadioButton (Weight and Height). I will do switch between the two categories. But the they share the same ListBox Controllers (listBox1 and listBox2).

                  有没有什么好方法可以更简单地清除所有 ListBox 项?我没有找到 ListBox 的 removeAll().我不喜欢我在这里发布的复杂的多线样式.

                  Is there any good method to clear all the ListBox items simpler? I didn't find the removeAll() for ListBox. I don't like my complex multi-lines style which I posted here.

                  private void Weight_Click(object sender, RoutedEventArgs e)
                      {
                          // switch between the radioButton "Weith" and "Height"
                          // Clear all the items first
                          listBox1.Items.Remove("foot"); 
                          listBox1.Items.Remove("inch");
                          listBox1.Items.Remove("meter");
                          listBox2.Items.Remove("foot");
                          listBox2.Items.Remove("inch");
                          listBox2.Items.Remove("meter");
                  
                          // Add source units items for listBox1
                          listBox1.Items.Add("kilogram");
                          listBox1.Items.Add("pound");
                  
                          // Add target units items for listBox2
                          listBox2.Items.Add("kilogram");
                          listBox2.Items.Add("pound");
                      }
                  
                      private void Height_Click(object sender, RoutedEventArgs e)
                      {
                          // switch between the radioButton "Weith" and "Height"
                          // Clear all the items first
                          listBox1.Items.Remove("kilogram");
                          listBox1.Items.Remove("pound");
                          listBox2.Items.Remove("kilogram");
                          listBox2.Items.Remove("pound");
                  
                          // Add source units items for listBox1
                          listBox1.Items.Add("foot");
                          listBox1.Items.Add("inch");
                          listBox1.Items.Add("meter");
                  
                          // Add target units items for listBox2
                          listBox2.Items.Add("foot");
                          listBox2.Items.Add("inch");
                          listBox2.Items.Add("meter");
                      }
                  

                  推荐答案

                  和Winform和Webform的方式不一样?

                  isn't the same as the Winform and Webform way?

                  listBox1.Items.Clear();
                  

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

                  上一篇:如何上下移动listBox中的项目? 下一篇:C#中的列表框刷新()

                  相关文章

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

                  1. <legend id='VLV8a'><style id='VLV8a'><dir id='VLV8a'><q id='VLV8a'></q></dir></style></legend>
                    • <bdo id='VLV8a'></bdo><ul id='VLV8a'></ul>

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