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

  3. <small id='lWSQp'></small><noframes id='lWSQp'>

      <tfoot id='lWSQp'></tfoot>

    1. 如何从列表框中删除选定的项目C#

      时间:2023-10-07

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

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

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

                问题描述

                我目前正在尝试查看用户在列表框中选择的所有文件和文件夹.目前,我可以使用 openfiledialogue 列出用户选择的内容,但是当我尝试从列表框中删除它时,我现在面临问题.我试图让用户单击文件旁边的复选框,然后按删除按钮将其删除

                i currently trying to view all the files and folder selected by the user in a listbox. At the Moment i am able to list what the user have chosen using the openfiledialogue HOWEVER i am now facing prob when i try to remove it form the listbox. i trying to allow the user to click on the checkbox beside the file and press the remove button to remove it

                这是我删除按钮的代码

                      private void button2_Click(object sender, EventArgs e)
                    {
                        for (int i = listView1.SelectedItems.Count - 1; i >= 0; i--)
                        {
                            listView1.Items.Remove(listView1.SelectedItems[i]);
                        }
                
                    }
                

                这是添加到列表框的文件以供参考,以防万一

                this is the add file to listbox for reference jsut in case

                    private void button1_Click(object sender, EventArgs e)
                    {
                
                        OpenFileDialog openfiledialog = new OpenFileDialog();
                        // Display open file dialog
                        openfiledialog.InitialDirectory = "C:\";
                        //openfiledialog.Multiselect = true;
                        openfiledialog.Title = "Lock File";
                        openfiledialog.Filter = "All Files | *.*";
                        openfiledialog.ShowDialog();
                
                
                        if (openfiledialog.FileName != "")
                        {
                
                        //move through FileInfo array and store in new array of fi
                            listView1.Items.Clear();
                            foreach (string file in openfiledialog.FileNames)
                            {
                                listView1.Items.Add(file);
                            }        
                        }
                
                    }
                

                我按下删除按钮没有任何反应,我在谷歌上看到了一些关于使用 selectionmode 的答案,但是当我使用它时,我的列表框没有 selectionmode 的属性,并且有红线下划线

                and i pressed the remove button nothing happen and i saw some answer on google on the using of selectionmode but when i used that, my listbox does not have the property of selectionmode and have red lines underlined

                推荐答案

                不要使用 listView1.SelectedItems 而是使用 listView1.CheckedItems 并更改您的 button2_click到:

                Instead of using listView1.SelectedItems use listView1.CheckedItems and change your button2_click to:

                private void button2_Click(object sender, EventArgs e)
                        {
                            foreach (ListViewItem i in listView1.CheckedItems)
                                listView1.Items.Remove(i);
                
                        }
                

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

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

                    • <bdo id='ZPVgm'></bdo><ul id='ZPVgm'></ul>
                      <tfoot id='ZPVgm'></tfoot>

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

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