I have a form that contains two listview controls.
When I clic开发者_开发问答k on each listview another smaller form will appear.
How do I get the smaller form to center on the calling listview control?
I think it has something to with the SetBounds but I am not sure.
Use this function:
static void CenterForm(Form f, Control c)
{
f.StartPosition = FormStartPosition.Manual;
var rc = c.PointToScreen(Point.Empty);
f.Location = new Point(rc.X + (c.Width - f.Width) / 2,
rc.Y + (c.Height - f.Height) / 2);
}
f
= your smaller form, c
= your listview.
精彩评论