• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

How do I control a child dialog's initial location?

Would someone be so kind as to tell me how, using C#, I can specify that a dialog will be drawn at the same location each time it's opened, which would require me to disable the cascading window default, where each new window is in front of and a little lower than the one opened before it?


Thanks,
RA
0
ba272
Asked:
ba272
1 Solution
 
Chester_M_RagelCommented:
For forms, there is a property called StartPosition. If you have a perticular location where you want to show the form, set that to manual and set the location property of the form to something where you want to show that. Or if you always want to show that in the center of the screen, or center of the parent you can select the correct property from the form property(StartPosition).
0
 
RomanPetrenkoCommented:
Chester_M_Ragel absolutely right, just little sample code:

// Shows dialog in desired location
private void ShowChildForm(Point DesiredLocation)
{
      ChildDialogForm f = new ChildDialogForm();
      f.StartPosition = FormStartPosition.Manual;
      f.Location = DesiredLocation;
      f.ShowDialog(this);
}
//Sample: how to call
private void button1_Click(object sender, System.EventArgs e)
{
      ShowChildForm(new Point(10,10));
}
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now