Mantorok wrote:
I basically have a base-class form and when the form closes and loads I want
it to serialise/deserialize the layout (where possible). My main interests
are size of control.
I would prefer it if the form handled this so that I don't have to code it
for each new control I create.
Kev
Ah, so you're talking about the size and location of just the form?
(Sorry for the really bad advice before, I misunderstood what you were
trying to do).
I would either use a base class to do this for all your forms, or use a
static method in a helper class that takes the form as an argument.
Example using a static method (can easily be adjusted to use a base class):
public static void RememberFormSize(Form myForm)
{
/* load height and width from where you saved it last and adjust
the form accordingly */
myForm.Resize += new EventHandler(myForm_Resize);
}
static void myForm_Resize(object sender, EventArgs e)
{
Form theForm = (Form)sender;
int height = theForm.Size.Height;
int width = theForm.Size.Width;
/* save height and width in a file, database, or whatever works for
your application */
}
I think typecasting the sender in the myForm_Resize method to a Form
should be okay. Somebody please correct me if it's not.
Hopefully this helps you, sorry again for the bad advice before.
Dan Manges