-
May 3rd, 2013, 08:35 AM
#1
Removing Controls from form
Hello everyone,
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)
{
test2.Controls.Remove(c);
}
}
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??
Screenshots below
Greetings and thanks,
Nico
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|