I created a form with multiple panel over it and I use panel control to display relevant information. Third panel have 20 text boxes and I want to check whether all the details are filled. So I simply used this code below.
private void Calculatebutton_Click(object sender, EventArgs e)
{
foreach(Control c in Controls)
{
if(c is TextBox)
{
Console.Beep();
if (!String.IsNullOrWhiteSpace(textbox.Text) &&
!String.IsNullOrEmpty(textbox.Text))
{
SaveToDatabaseButton.Enabled = true;
}
}
}
}
The problem is that the condition in the if statement is getting false, I cannot hear any beep sound or the other button enabled. if I changed from "c is TextBox" to "c is Panel" i can hear the beep sound for three times. I also tried the code like this
if(c is TextBox)
{
c.Text = " ";
}
But nothing works. Please help me to overcome this problem. Thanks in advance.