revelvice
revelvice

Reputation: 368

Set control location to original

Is there any way to set control location to original (initialize time)?
I changing location on many controls, and in some situation I must change they location to original.

Upvotes: 0

Views: 268

Answers (1)

Random Dev
Random Dev

Reputation: 52280

just remember the original values and reset them - so before setting your new ones to something like

oldX = control.X

if you have really a lot of controls you can to something like this

private Dictionary<Control, int> OldValuesX = new Dictionary<Control, int>();

public void SaveProperties()
{
   foreach (var ctr in this.Controls)
     OldValuesX[ctr] = ctr.X;
}

and later

public void ResetProperties(Control ctr)
{
   ctr.X = OldValuesX[ctr];
}

just extent this to your need (for example save more properties than X-Values in a Tuple, self-defined struct, etc.

Upvotes: 2

Related Questions