是否可以在 WinForms 中旋转按钮控件? [英] Is it possible to rotate a button control in WinForms?

查看:21
本文介绍了是否可以在 WinForms 中旋转按钮控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 WinForms 中以特定角度旋转按钮或任何控件?如果是,怎么办?

Is it possible to rotate a button or any control at a particular angle in WinForms? If so, how?

推荐答案

您不能旋转控件. WinForms 使用的本机 API 控件根本不支持这一点.

You can't rotate controls. That's simply not supported by the native API controls that WinForms uses.

人们可能想知道为什么它甚至应该得到支持.您可能会尝试做些什么来旋转按钮控件?首先将其绘制在具有不同形状的不同位置会容易得多,而不是尝试旋转现有控件.(请注意,您还可以在运行时调整控件的大小和位置,如果这符合您的需要.调查 SizeLocation 属性.)

And one might wonder why it even should be supported. What could you possibly be trying to do that you'd need to rotate a button control? It would be much easier to draw it in a different place with a different shape in the first place, rather than trying to rotate an existing control. (Do note that you can also resize and reposition a control at run-time, if that would fit your needs. Investigate the Size and Location properties.)

唯一的解决方法是将控件的图像绘制到位图,隐藏控件,然后将位图绘制到窗体上您希望它出现的位置.当然,这不会导致用户可以交互的控件.他们将无法点击按钮的图像,因为它不是真正的按钮.如果这对您来说是可以接受的,那么您可能应该首先使用图像,而不是按钮.

The only workaround is to draw the control's image to a bitmap, hide the control, and draw the bitmap onto the form in the location you want it to appear. Of course, that won't result in a control that the user can interact with. They won't be able to click an image of a button, because it's not a real button. If that's acceptable to you, you should probably be using an image in the first place, rather than a button.

这篇关于是否可以在 WinForms 中旋转按钮控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆