时间:2019-03-17 标签:c#pictureboxdock问题

发布于 2024-12-21 04:41:20 字数 296 浏览 5 评论 0原文

我希望将图片框停靠在表单的右上角,但是当我使用
pictureBox1.Dock = DockStyle.Right;
图片框中的图像位于正确的位置,但其背景颜色为我的表单的整个高度创建了一条拉伸条纹。如果我使用它不会出现
pictureBox1.Dock = DockStyle.Left;

我不知道为什么会这样,有人可以帮助我吗?

我希望它粘在右上角,当我尝试将窗口大小调整为较小时 - 使其消失,当我尝试将窗口大小调整为更大窗口时 - 保持它仍然粘在右上角。

I wish to dock my picturebox to right-top corner of my form, but when I use
pictureBox1.Dock = DockStyle.Right;
the image from picturebox is in the right place, but its background color creates a streatched stripe for whole height of my form. It doesn't appera if I use
pictureBox1.Dock = DockStyle.Left;

I have no idea why is it so, can anyone help me?

I wish it was sticked to right top corner and when I try to resize the window to smaller - make it disappear, when I try to resize to bigger window - keep it still sticked to righttop corner.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妄断弥空 2024-12-28 04:41:20

按照您想要的方式放置图片框并设置 Anchor 属性:

pictureBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;

您的图片框就会按照您想要的方式运行。

Place the picturebox like you want it to be placed and set the Anchor property like that:

pictureBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;

and your picturebox behaves like you want it to.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文