While working on VSToolkit and VSMenus, I had a problem in starting the AddIn form centered in the screen; I tried to change “StartPosition” to Center Screen and Center Parent with no success, the form keep opening in the left top corner of the screen which is very annoying to the end users.
I found that the tool is ignoring the “StartPosition” property and is using the “Location” property instead, but the location cannot be fixed since the screen resolution is changeable.
To workaround this issue I have created the following code segment that gets the screen resolution and set the form boundaries to the screen center
Just add the following code segment to your form load:
Me.SetBounds(Math.Round((Screen.PrimaryScreen.Bounds.Width / 2) - (Me.Width / 2), 0), Math.Round((Screen.PrimaryScreen.Bounds.Height / 2) - (Me.Height / 2), 0), Me.Width, Me.Height)
Hope this helps!
Mohammad R. Daoud
MCP, MCBMSP, MCTS, MCBMSS
Software Development Manager
+962 - 79 - 999 65 85