If I have the following code and want to align button control to horizontally center of the Form.
let myForm:Form = new Form()
myForm.Text <- "myForm"
myForm.Height <- 500
myForm.Width <- 500
let button:Button = new Button()
button.Text <- "Click"
myForm.Controls.Add(button)
button.Location <- Point(200, 20)
// Using this code to align this control to center
Please suggest me a good way of horizontally center aligning a control. The above will not work if Form is maximized. And please suggest me to improve the code if there are any other good practices.
Thanks
Translating @ispiro’s answer to F# – if you want to recenter every time the form is resized
If this is only happending in the constructor, you can just do