The easiest way to center any component. may be helpful to someone. Right click on Project β Add β Class
Update this class with the code below.
public static class MyClass { public static void center(this Control component) { float compWidth = component.Width; float parentWidth = component.Parent.Width; float middled = (parentWidth / 2) - (compWidth / 2); component.Left = Convert.ToInt32(middled); } }
and then you can cut any component. you can use any component like this
MyLabel.center(); MyPanel.center();
source share