May 3rd, 2013, 08:35 AM
Removing Controls from form
First of all, i'm new to C#. I've bought a book to learn the basics and now i'm trying to write a little program.
I'm having problems with removing controls from a form.
Small explanation of the program i'm writing.
I search a folder every 30 seconds to see what files there are inside.
When i find files, i create a label (to display the name) and a button (to open the file). Every time i refresh, i need to clear the existin labels and buttons so they don't mixup.
I do this using a foreach loop:
foreach (Control c in test2.Controls)
if (c.Name.Contains("DYNAMIC") == true)
I set the name of the label to DYNAMIC_LBL(index) and the buttons to DYNAMIC_BTN(index).
Sometimes it works, sometimes it only deletes the buttons....
Does anyone know what i am doing wrong??
Greetings and thanks,
Click Here to Expand Forum to Full Width