When is the proper time to restore the UI layout settings of a System.Windows.Forms.Control?
I tried this:
FooBarGadget control = new FooBarGadget(); parent.Controls.Add(control); control.FobnicatorWidth = lastLayoutSettings.FobWidth;
No cigar. Reason? control isn’t finished laying out its internals; it’s in its default size of 100×100 pixels after construction. Once it’s done loading and actually displays in the UI, it will be 500×500 pixels. Therefore, setting the FobnicatorWidth to 200 pixels fails; it’s larger than the control.
Is there a control.Loaded event – somwehere where I can restore my saved UI settings?
If you’re creating this control as part of loading a new
Form, a good place to reload saved settings would be in Form.OnLoad (or respond to the the Form.Load event). Another event that might be helpful is Control.HandleCreated, which happens when the underlying window of your control is created.If neither of these helps, perhaps more information about your particular scenario will help us get to a better answer.