Form Positioning

  • Thread starter Thread starter Azrael
  • Start date Start date
A

Azrael

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.
 
Every Control has a PointToScreen method.

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

pointToScreenOfTextBox contains the screen coordinates of your textbox.
 
Back
Top