Popup Dialog Position

D

Dave Anson

I have created a custom datetimepicker (following on from a previous thread
"DateTimePicker color").

How do I set the position of a Modal Dialog (a control containing a month
calendar) relative to a control (containing a textbox and a button) on a
windows form? I.e. I want the modal dialog to open just beneath the control
that opened the dialog.

--
Regards
JTC ^..^


Any other suggestions about creating a custom datetime picker would also be
appreciated.
 
N

Nicholas Paldino [.NET/C# MVP]

Dave,

I would believe it is like any other form. First, you would set the
StartPosition of the dialog to FormStartPosition.Manual. You would then set
the Location property to the location that you want it to open. This
location is relative to the screen. You would have to calculate the
position based on the control that is showing the dialog. This can be done
easily with the PointToScreen method on the Control class.
 
D

Dave Anson

Dave,

I would believe it is like any other form. First, you would set
the
StartPosition of the dialog to FormStartPosition.Manual. You would
then set the Location property to the location that you want it to
open. This location is relative to the screen. You would have to
calculate the position based on the control that is showing the
dialog. This can be done easily with the PointToScreen method on the
Control class.

Thanks for the help. The following code resolved the issue....


// Where "this" is my control and, as suggested,
// the "StartPosition" property of the form
// which will appear as a dialog is set to Manual.


_calendarPopUp.Location = this.PointToScreen(new Point(0, this.Height));


// ShowDialog below the control


this._calendarPopUp.ShowDialog();
 

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