I have a panel (with autoscrolling) that contains randomly placed UserControls
, I want to save the locations of these controls and load them back at a later time so they are placed exactly where they were before.
What's the proper way to do this in .NET? At the moment this is what I'm saving to the database as X,Y:
X: Math.Abs(panel.AutoScrollPosition.X) + control.Location.X;
Y: Math.Abs(panel.AutoScrollPosition.Y) + control.Location.Y;
And when I load the control I do: control.Location = new System.Drawing.Point(X, Y);
But I think I'm missing something, because of the way the AutoScroll behaves in .NET. Sometimes I find the controls misplaced (unlike their old position) after loading.
Been boggling my mind for a while now, I really hope I'd find some information here.