If using this property with the Show() method of the Form class you will not get a centered Position to the calling form although setting the StartPosition to CenterParent.
CenterParent is defined as: "The form is centered within the bounds of its parent form". But in this case the parent would be null so the Show method displays the form only at default position.
To achieve the centered behavior use code like this:
private void btnForm2_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Show(); CenterFormTo(f2, this);
}
/// <summary>The Form '<paramref name="form"/>' will be displayed centered in the '<paramref name="containerForm"/>'</summary>
protected void CenterFormTo(Form form, Form containerForm)
{
Point point = new Point(); Size formSize = form.Size;
Rectangle workingArea = Screen.GetWorkingArea(containerForm);
Rectangle rect = containerForm.Bounds;
point.X = ((rect.Left + rect.Right) - formSize.Width) / 2;
if (point.X < workingArea.X) point.X = workingArea.X;
else if ((point.X+formSize.Width) > (workingArea.X+workingArea.Width))
point.X = (workingArea.X + workingArea.Width) - formSize.Width;
point.Y = ((rect.Top + rect.Bottom) - formSize.Height) / 2;
if (point.Y < workingArea.Y) point.Y = workingArea.Y;
else if ((point.Y+formSize.Height) > (workingArea.Y+workingArea.Height))
point.Y = (workingArea.Y + workingArea.Height) - formSize.Height;
form.Location = point;
}
This is a reflected version from the protected Form method: CenterToParent().