Ejemplo n.º 1
0
        /// <summary>
        /// Enables the and disable all controls.
        /// </summary>
        /// <param name="panel">The panel.</param>
        /// <param name="enable">if set to <c>true</c> [enable].</param>
        public static void EnableAndDisableAllControls(Panel panel, bool enable)
        {
            if (!panel.HasControls())
            {
                return;
            }


            foreach (Control ct in panel.Controls)
            {
                if (ct.GetType() == typeof(TextBox))
                {
                    TextBox control = (TextBox)ct;
                    control.Enabled = enable;
                }

                if (ct.GetType() == typeof(RadioButtonList))
                {
                    RadioButtonList control = (RadioButtonList)ct;
                    control.Enabled = enable;
                }


                if (ct.GetType() == typeof(RadioButton))
                {
                    RadioButton control = (RadioButton)ct;
                    control.Enabled = enable;
                }


                if (ct.GetType() == typeof(DropDownList))
                {
                    DropDownList control = (DropDownList)ct;
                    control.Enabled = enable;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Clears all controls.
        /// </summary>
        /// <param name="panel">The panel.</param>
        public static void ClearAllControls(Panel panel)
        {
            if (!panel.HasControls())
            {
                return;
            }


            foreach (Control ct in panel.Controls)
            {

                if (ct.GetType() == typeof(TextBox))
                {
                    TextBox control = (TextBox)ct;
                    control.Text = string.Empty;
                }

                if (ct.GetType() == typeof(DropDownList))
                {
                    DropDownList control = (DropDownList)ct;
                    control.ClearSelection();
                }

                if (ct.GetType() == typeof(RadioButtonList))
                {
                    RadioButtonList control = (RadioButtonList)ct;
                    control.ClearSelection();
                }
            }
        }