I am using the System.Windows.Forms.Form.ShowDialog() method, the problem is that it always opens at the top left or right corner of my application, depending on the Right to Left layout. Is it possible to center it in the middle of the screen or application?
Thanks
use the CenterToScreen() Method in the constructor of the form class.
Forms. OpenFileDialog component opens the Windows dialog box for browsing and selecting files. To open and read the selected files, you can use the OpenFileDialog. OpenFile method, or create an instance of the System.
To achieve this select the form you want to start in the center screen then go to properties and set the Startposition property to CenterScreen. It's not advisable to call this directly in your source code, “Do not call this directly from your code.
Position the panel in the center of the form using the designer, and then clear the Anchor property, so it is not anchored to any edge. This will keep it centered when the form resizes, without resizing the panel itself.
If you're using a Form, you can use Form.StartPosition. And here is more about this enumeration: link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With