如何避免在列表框中追加 [英] How to avoid append in listbox

查看:78
本文介绍了如何避免在列表框中追加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在使用C#时遇到列表框中的一个问题。请看下面的详细信息,



我有两个按钮和一个列表框。点击第一个按钮,当我点击第二个按钮列出所选目录文件时,我将获得C盘上的文件/目录列在列表框中。

当我点击第一个按钮后,我可以看到文件/目录,当我点击第二个按钮时,第二个按钮的输出会附加第一个按钮输出。



我需要在每个按钮的列表框中列出结果。我不希望数据被追加。



请建议

Hi,

Am facing one problem in my listbox on using C#. Please see the details below,

I have two buttons and one listbox. On clicking first button i will get files/directories present on C drive get listed on listbox when I clicked second button to list down selected directory files.
When I clicked first button I can see file/directories later when I clicked second button the output of second button is getting appended with first button output.

I need results to be listed on listbox for each button. I don't want data to get append.

Please advice

推荐答案

当你点击第二个按钮,你应该清除ListBox中的项目,

When you click the second button, you should clear the items in the ListBox,
listBox1.Items.Clear();


这篇关于如何避免在列表框中追加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆