Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Comments
[no name] 5-Jun-14 20:45pm    
Okay so clear the data from the listbox before you fill it again.
Sergey Alexandrovich Kryukov 5-Jun-14 21:30pm    
ListBox? Which one? Full type name, please.
The request makes no sense at all. Adding or showing some items in a list box is not a problem it all. The quality of a solution does depend on whether you call it "append" or not. It's actually "Add"/"AddRange". I would say, case closed.
—SA

1 solution

When you click the second button, you should clear the items in the ListBox,
C#
listBox1.Items.Clear();
 
Share this answer
 
Comments
abhicoolhot 25-Jun-14 16:16pm    
Thanks a lot your suggestion.. I got an expected result. One small query, in list box I have listed 10 items in list. If am selecting the first item then how can I open the selected first item using button click?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900