總網頁瀏覽量

2011年10月23日 星期日

[VB.NET] 讓視窗開啟位置固定在中間


'將下列Sub放置到  Me.Resize,當控制項變化時會自動調整位置

  Private Sub WindowToCenter()
        Dim sx As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim sy As Integer = Screen.PrimaryScreen.Bounds.Height
        Me.Left = (sx - Me.Width) / 2
        Me.Top = (sy - Me.Height) / 2
    End Sub

沒有留言:

張貼留言