Hi all..
I am displaying a form from thread. I set its startposition property to centreparent but its displayed on topleft corner.. I am displaying form using...
error_msg.ShowDialog();
//where error_msg is object of form
Please help me to solve this problem..
Problem in displaying form in centre parent
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Scott LysleRank #49 · 31K reputationPosted Jul 3, 2008, 6:02 AM EDT
That is the the behavior you get when adding a child form to a parent. You can get passed that by changing the location of the child form on the child form's load event.
Try this:
private void frmChild_Load(object sender, EventArgs e)
{
Point p = new Point(this.ParentForm.Width / 2 -
this.Width/2,
this.ParentForm.Height / 2 - this.Height/2);
this.Location = p;
}
try abcRank #6,639 · 260 reputationPosted Jul 3, 2008, 9:09 PM EDT
Thanks for reply but its not working such .
I also tried with
Point p = new Point(parentform.Left + parentform.Width/2 , parentform.Top + parentform.Height / 2);
but problem is it gives parentform.left=0..............