Hello frnds,
while I'.m click new i want the clear Container Control in my application
can it possible or nt ...
i'hv just started work c# and sql server ...so
Thanks
Shouketh
Loading
Hello frnds,
while I'.m click new i want the clear Container Control in my application
can it possible or nt ...
i'hv just started work c# and sql server ...so
Thanks
Shouketh
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
naura paxPosted Jul 15, 2009, 5:17 AM
You can create a function in which you have to pass container control.
For eg, following is for windows application in which you can pass a Panel control.
public static void Clear(Control.ControlCollection ctl)
{
foreach (Control ctrl in ctl)
{
if (ctrl.GetType().ToString() == "System.Windows.Forms.TextBox")
ctrl.Text = "";
else if (ctrl.GetType().ToString() == "System.Windows.Forms.ComboBox")
{
((ComboBox)ctrl).SelectedIndex = -1;
ctrl.Text = "";
}
else if (ctrl.GetType().ToString() == "System.Windows.Forms.CheckBox")
((CheckBox)ctrl).Checked = false;
else if (ctrl.GetType().ToString() == "System.Windows.Forms.RadioButton")
((RadioButton)ctrl).Checked = false;
else if (ctrl.GetType().ToString() == "System.Windows.Forms.DateTimePicker")
((DateTimePicker)ctrl).Value = DateTime.Today;
else if (ctrl.GetType() == typeof(CheckedListBox))
{
CheckedListBox lst = (CheckedListBox)ctrl;
for (int i = 0; i < lst.Items.Count; i++)
{
lst.SetItemCheckState(i, CheckState.Unchecked);
}
}
}
}
Hope that helps.