ShowDialog displays in different position on different machines

Torquinian 21 Reputation points
2025-12-05T10:49:47.3033333+00:00

I have compiled an EXE from Visual Basic using Visual Studio 2022 Version 17.14.21.

When I run it on my Windows 11 laptop, the subject of the ShowDialog command is displayed in the correct position (CenterScreen, see image), but on a new Windows 11 Microsoft Go it is displayed at the top left and the rest of the screen is covered, so that only the ShowDialog Form is seen (On an old Microsoft Go it displayed correctly).

It would be beneficial to the customer if it could display CenterScreen and not obliterate the remainder of the display.

Any ideas would be appreciated.

Developer technologies | VB
{count} votes

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2025-12-05T10:49:56.34+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The issue you're experiencing with the ShowDialog command displaying in different positions on different machines could be related to how the StartPosition property is set for your dialog. The ShowDialog method typically centers the dialog based on the StartPosition property of the form. If the StartPosition is not set correctly, it may default to a position that does not center the dialog on the screen.

    To ensure that your dialog appears centered on the screen, you can explicitly set the StartPosition property of your form to FormStartPosition.CenterScreen. Here’s a code snippet that demonstrates how to do this:

    Dim dialog As New YourDialogForm()  ' Replace with your dialog form
    
    dialog.StartPosition = FormStartPosition.CenterScreen
    
    dialog.ShowDialog()
    

    Additionally, ensure that the display settings on the different machines are consistent, as variations in screen resolution or scaling settings can also affect how forms are displayed.

    If the problem persists, consider checking for any specific display settings or configurations on the new Microsoft Go device that might be influencing the dialog's positioning.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.