I have a label centered by the X coordinate on a form, and I'm trying to make it adjust its location on form resize. So, I'm handling the Resize event to update label Location property.
private void SecondaryWindow_Resize(object sender, EventArgs e)
{
lblStartPointX = this.Width / 2 - lblSecondary1.Width / 2;
lblStartPointY = lblSecondary1.Location.Y;
lblSecondary1.Location = new Point(lblStartPointX, lblStartPointY);
}
It seems I can't directly assign some value to lblSecondary1.Location.X property (compiler considers it a mistake), so I came up with this code.
But it strikes me as not very efficient way to do the task... Just how much Point objects are created if you constantly resize the window, I wonder?