开发者

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 开发者_StackOverflow中文版situation I must change they location to original.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜