I am very new to programming, so hopefully this is not a stupid question. I have created a WinForm app that will create a csv file based on information entered in several textboxes. I want the last set of textboxes and their corresponding labels to appear in the GUI only when a corresponding number has been entered into a specific text box. I have the appropriate number of textboxes appearing when a number is entered in the controlling textbox, but I am not sure how to get the labels to appear as well. When the number in the controlling textbox is deleted or changed, I would like the other textboxes and labels to disappear, then the correct number to reappear.
Here is my code for getting the textboxes to appear. I'm not sure how to get the labels to appear, or how to reset the boxes when the number changes in the SitesTextBox.
//Number entered into Sites Textbox enables Site Repeater Textboxes
private void SitesTextBox_TextChanged(object sender, EventArgs e)
{
int repeaterSites;
string SitesInput = SitesTextBox.Text;
int.TryParse(SitesInput, out repeaterSites);
for (int i = 1; i <= repeaterSites; i++)
{
foreach (Control SiteTextBox in this.Controls)
{
if (SiteTextBox.Name == "SiteTextBox"i.ToString())
{
SiteTextBox.Visible = true;
}
}
}
}