hello
In my Form I had used multiple container such as panel,group box.and as per my requirement i have to clear all the controls which are reside in container. For this i have wrote a code as follows:-
foreach (Control x in ControlContainer.Controls)//Error
{
if (x is System.Windows.Forms.TextBox)
((TextBox)x).Text = String.Empty;
else (x is System.Windows.Forms.ComboBox)
{
((ComboBox)x).SelectedIndex = -1;
((TextBox)x).Text = String.Empty;
}
}
But its not working properly, i’m receiving error like:’object’ does not contain a definition for ‘Controls’
please help
Somewhat recursive example from ASP.NET Forums:
I don’t think the
ControlContainerreturns the controls in the way you think.