I am trying to make a showdialog() mdi child form to be visible in a specific place inside its parent form. Is there any way to achieve this?
Thanks in Advanced
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Apr 23, 2011, 3:46 PM
Sam HobbsPosted Apr 23, 2011, 2:53 PM
If you need to show the form in the same location relative to the desktop but as a child of another form, then you could convert the desktop's position to a position in the parent form's client area. I am not sure what would happen if the coordinates were to be outside of the parent form; I assume you would get negative values that would cause a portion of the form to not show.
Okay, I did a bit of looking. Apparently a Form's Location Property is always in Screen coordinates. I will be surprised if that applies to child forms too but the documentation does not say that. Also look at the PointToClient and the PointToScreen methods.
George ParoglouPosted Apr 23, 2011, 2:16 PM
VulpesPosted Apr 23, 2011, 1:53 PM
This will be impossible unless the starting position of form1 (when normal) is manually controlled because otherwise we won't know where Windows is going to put it.
The code I posted earlier will place form2 in the same relative position within form1 even if it's maximized but not, of course, in the same absolute position.
George ParoglouPosted Apr 23, 2011, 1:15 PM
VulpesPosted Apr 22, 2011, 6:13 PM
A maximized form is always going to cover the entire desktop apart from the TaskBar.
Are you saying that you want a normal form to do the same thing or do you want it to be placed (with its normal size) in the top left hand corner of the desktop?
The code to do the latter would be:
However, for this to work, there would have to be no parent/child relationship between form1 and form2. In effect the desktop would become form2's parent.
George ParoglouPosted Apr 22, 2011, 3:56 PM
There isn't any way to specify the location point of a maximized form to be the same in the case of a normal window form?
VulpesPosted Apr 21, 2011, 5:07 AM
child.StartPosition = FormStartPosition.Manual;
child.Location - new Point(0, 0); // place in top left hand corner of parent
// or
child.Location - new Point(100, 100); // place the left hand corner of child at co-ordinates (100,100) of parent
George ParoglouPosted Apr 21, 2011, 4:37 AM
VulpesPosted Apr 20, 2011, 6:31 PM
Suthish NairPosted Apr 20, 2011, 5:19 PM