0

well i didn't know how to name it, well my problem is that when i put center parent its centered from the form that was open obviously but when i put my program after the screen resolution like it cuts more then the half of the program and i open then other form as center parent the form appears like completely touching the end of the screen it doesn't cut offs, i need like if my program is cutting off from screen the second form have to cut off too.

if you can't understand me here is a picture.

Normal : http://img59.imageshack.us/i/75323778.png/

Error : http://img713.imageshack.us/i/58001921.png/


Please Help :S

3
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by xfrolox
0

Just set your Parent form property using this code:

'if you want your other form to be in the center of your Parent form
Me.StartPosition = FormStartPosition.CenterParent

'if you want your form to be display in the center of the screen
Me.StartPosition = FormStartPosition.CenterScreen
0

Me.StartPosition = FormStartPosition.CenterScreen

goes to center and it works but

Me.StartPosition = FormStartPosition.CenterParent works but still doesn't go with the program when it is cut against the screen resolution..

0

if you want to set your form position manually then you can use this code:

me.location = new point(9,158)
0

nope, because when i move my form and i make the second windows to open it will go to the place manually and what i want is to be in the center of the windows of the first form, i can do that to make position in CenterParent but when i put it against the resolution of the screen ( the end of the 4 sides of the monitor screen ) the second form wont get cut too, it just get like the position in the max, 0 doesn't go farther than the screen...

1
Public Class Form1

    Sub keepCentered()
        Dim x As Integer = CInt((Me.Left + (Me.Width - Form2.Width) / 2))
        Dim y As Integer = CInt((Me.Top + (Me.Height - Form2.Height) / 2))
        Form2.Location = New Point(x, y)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Form2.Show()
        Form2.TopMost = True
        keepCentered()
        Me.Location = New Point(1290, 155)
    End Sub

    Private Sub Form1_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
        keepCentered()
    End Sub

End Class

Edited by codeorder: n/a

Votes + Comments
Cuz it worked :P
0
Public Class Form1

    Sub keepCentered()
        Dim x As Integer = CInt((Me.Left + (Me.Width - Form2.Width) / 2))
        Dim y As Integer = CInt((Me.Top + (Me.Height - Form2.Height) / 2))
        Form2.Location = New Point(x, y)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Form2.Show()
        Form2.TopMost = True
        keepCentered()
        Me.Location = New Point(1290, 155)
    End Sub

    Private Sub Form1_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
        keepCentered()
    End Sub

End Class

Thx it worked perfectly i put it ShowDialog and it worked with you code i used

Sub keepCentered()
        Dim x As Integer = CInt((Me.Left + (Me.Width - Form2.Width) / 2))
        Dim y As Integer = CInt((Me.Top + (Me.Height - Form2.Height) / 2))
        My.Forms.Form2.Location = New Point(x, y)
    End Sub

Than in the button that shows the other form

Private Sub HRBtn_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles HRBtn.MouseClick
        If e.Button = Windows.Forms.MouseButtons.Left Then
            My.Forms.Form2.ShowDialog()
            Me.keepCentered()
        End If
    End Sub

Rep+ & Solved Thread tys :P

0

Well for anyone that needed this i made a bit correction instead of My.Forms.Form2.ShowDialog() is My.Forms.Form2.Show()

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.