使控件位于顶部
我有这张图片,我希望它位于另一张图片之上。
(窗口窗体应用程序,C#)
I have this one Image and I want it to be on top of another image.
(window form application, c#)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在代码中,您可以进行一些调用。 BringToFront 和 SendToBack< /a> 可能是最简单的:
您也可以使用以下命令从控件的父容器中控制它:
Control.ControlCollection.SetChildIndex。例如:
否则只需在设计器中单击“置于前面”或“发送到后面”,正如 @KeithS 已经回答的那样。
In the code you have a few of calls you can make. BringToFront and SendToBack are probably the simplest:
Also you could control that from the control's parent container using
Control.ControlCollection.SetChildIndex. For example:
Otherwise just click "Bring to Front" or "Send to back" in the designer, as @KeithS has already answered.
如果一个控件与另一个控件部分重叠,并且您希望其中一个位于顶部,请右键单击设计器中想要位于顶部的图像,然后选择“置于前面”。您可以使用“发送到后面”功能将您想要的图像放在另一张图像后面。
如果您想要部分透明度,例如顶部图像上的 alpha 遮罩或两个图像之间的渐变混合,您可能需要 WPF 图形的更高级功能。您可以在 WinForms 中执行逐像素效果,但 Winforms 中没有内置任何内容来处理图像透明度,并且 Winforms 中图像的逐像素操作不会利用任何图形加速(100% CPU) ,运行时的开销会进一步减慢您的速度)。
If it's one control partially overlapping another, and you want one or the other on top, right-click the image you want on top in the designer, and choose "Bring To Front". There is a "Send To Back" that you can use on the image you want behind the other.
If you want partial transparency, like an alpha mask on the top image or a gradient blend between two images right on top of the other, you'll probably need the more advanced capabilities of WPF graphics. You CAN do pixel-by-pixel effects in WinForms, but there isn't anything built in to Winforms to handle image transparency, and per-pixel manipulation of an Image in Winforms won't take advantage of any graphics acceleration (100% CPU, with the runtime's overhead slowing you down further).