Questions Received:
How to set/unset the controls in the Windows FormSolution:
To find the required using the accessible name of the controls, use the 'find' method inForm.Controls.find().
public static void set(Control form,string ctrlName,string DBName)
{
foreach (Control ctrl in form.Controls.Find(ctrlName, true))
{
if (ctrl is CheckBox)
{
CheckBox chk = (CheckBox)ctrl;
if (chk != null)
{
chk.Checked = true;
}
}
if (ctrl is TextBox)
{
TextBox tb = (TextBox)ctrl;
if (tb != null)
{
tb.Text = DBName;
}
}
}
}
[Note:] Assume, Form-->this, ctrlName-->AccessibleCtrlName, DBName-->TextFieldEntry
You can use this function to manage different controls in the Form
No comments:
Post a Comment