[RESOLVED] [2005] AboutBox location versus OpenFileDialog Location problem
This seems rather strange to me and was wondering what the solution is:
If i have a Form (Form1) and add a new item, an AboutBox, to my project (AboutBox1). If I open this Aboutbox from a menuStrip item (Help -> About), the AboutBox always appears in the centre of my form and it doesn't matter where the form is located or what size it is. That's great.
If I have a File -> Open menu item and want to open an OpenFileDialog, it doesn't have the same behaviour. No matter what size or where my form is on the screen the dialog always opens in the same location which I really need to stop it from doing.
Does anyone have answers to why this happens and more importantly - a solution so the OpenFileDialog does what the AboutBox does naturally.
Re: [2005] AboutBox location versus OpenFileDialog Location problem
Bad luck I'm afraid. Your AboutBox is itself a form, thus you can set its StartPosition property. The OpenFileDialog is NOT a form itself. It is a component that, when you call its ShowDialog method, creates a form for you with all the required controls and functionality, which it then displays. You have no direct access to that form so you cannot set its StartPosition property before its dispalyed and you cannot set its Loaction property after its displayed. Your only option would be to use the SetWindowPos API to move the window after it's been displayed, but that will not be immediate.
Re: [2005] AboutBox location versus OpenFileDialog Location problem
ok, thanks for the info. I'll look into the SetWindowPos API and see how it works out. I'll mark this resolved.