Form Positioning

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.
 
R

Roman Wagner

Every Control has a PointToScreen method.

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

pointToScreenOfTextBox contains the screen coordinates of your textbox.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top