all groups > dotnet windows forms > february 2007 >
You're in the

dotnet windows forms

group:

Form Positioning


Form Positioning Azrael
2/7/2007 7:51:43 AM
dotnet windows forms:
Hi.

I have created custom control from TextBox. This control has lookup
capability, users can press F4 and a dialog form is shown to provide
help with input. This works fine however I would like to open dialog
form just below my control. At this moment windows is deciding where
to place the dialog.

My first try was:

//In KeyDown event
DialogForm.StartPosition = FormStartPosition.Manual;
DialogForm.Location = new Point(this.Location.X, this.Location.Y +
this.Height);

This didn't work ofcourse because my custom control has location
relative to form in which is placed. And this Form (ParentForm) is
also a MDIChild.

Is it possible to find true position of my control so that I can open
DialogForm just below it??

Thanks in advance.
Re: Form Positioning Roman Wagner
2/7/2007 8:25:20 AM
Every Control has a PointToScreen method.

Point pointToScreenOfTextBox =
this.PointToScreen(this.textBox.Location);

pointToScreenOfTextBox contains the screen coordinates of your textbox.
AddThis Social Bookmark Button