简体   繁体   中英

how to avoid the flickering of a windows for when loading its components/classes.

i'm having a problem with regards on flickering of windows form while loading its components.

private void frmOrderhdr_Load(object sender, EventArgs e)
         {
            InitializeInstanceObj();
            InitializedControls();
            InitializedGridControls();
            InitializeFields();
            InitializeComboBoxDataSources();
            ControlSettings();
            PopulateFieldsUpdate();
            SetControlPermission();
            InitializedGrid();
        }

as you can see, i have lots of functions inside the Form_Load events. is there any work around to prevent the flickering?

Thanks in advance.

I think SuspendLayout and ResumeLayout would work:

private void frmOrderhdr_Load(object sender, EventArgs e) {
        SuspendLayout();
        InitializeInstanceObj();
        InitializedControls();
        InitializedGridControls();
        InitializeFields();
        InitializeComboBoxDataSources();
        ControlSettings();
        PopulateFieldsUpdate();
        SetControlPermission();
        InitializedGrid();
        ResumeLayout(true);
}

If needed, you can also try setting your form's Visible to false initially. Then after loading all the stuff, set it to true back. This can also be applied to each of component.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM