I have tried the following codes. The maximised window worked but the centralizing failed. How centralize a form in maximised window?

Me.WindowState = FormWindowState.Maximized

         Me.Left = (Screen.PrimaryScreen.Bounds.Width \ 2) - (Me.Width \ 2)
         Me.Top = (Screen.PrimaryScreen.Bounds.Height \ 2) - (Me.Height \ 2)

        Me.StartPosition = FormStartPosition.CenterScreen

Put the centralizing code before the maximize:

Me.Left = (Screen.PrimaryScreen.Bounds.Width \ 2) - (Me.Width \ 2)
         Me.Top = (Screen.PrimaryScreen.Bounds.Height \ 2) - (Me.Height \ 2)

        Me.StartPosition = FormStartPosition.CenterScreen
        
        Me.WindowState = FormWindowState.Maximized

Thanks

Hi,

Try This :

In Property Sheet of the form, set this property :
StartPosition=CenterScreen

Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.