Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在放置一些带有坐标的图片框
pictureBox.Location = new Point(x, y);
如果我选择75,40 图片框出现在该坐标中但在左角的坐标,我希望图片框75,40居中显示。像这样:
75,40
这很简单,你只需要用图片框的大小减去你想要的位置,然后除以 2。
所以,而不是这个
图片框.位置=新点(x,y);
你要这个
pictureBox.Location = new Point(x - pictureBox.Size.Width/2, y - pictureBox.Size.Height/2);