Translate

Samstag, 4. November 2017

C# Enable/ disable all GUI elements

private void EnableGui(Control control, bool enabled)
        {
                foreach (Control c in control.Controls)
                {
                    EnableGui(c, enabled);
                }
                control.Enabled = enabled;
        }


With UIThreadInvoke:
private void EnableGui(Control control, bool enabled)
        {
            this.UiThreadInvoke(() =>
            {
                foreach (Control c in control.Controls)
                {
                    EnableGui(c, enabled);
                }
                control.Enabled = enabled;
            });
        }

Keine Kommentare:

Kommentar veröffentlichen