Center form on screen or on parent

后端 未结 4 1263
生来不讨喜
生来不讨喜 2020-12-28 10:07

Since built in functionality for positioning forms in VB.NET are not always suitable to use I try to make my sub to do that.

But I missed something...



        
4条回答
  •  有刺的猬
    2020-12-28 10:14

    I had the problem with StartPosition = CenterParent not working. I solved it calling the form with .ShowDialog() instead of .Show():

    ' first you should set your form's Start Position as Center Parent
    Private Sub button_Click(sender As Object, e As EventArgs) Handles button.Click
        MyForm.ShowDialog()
    End Sub
    

提交回复
热议问题