Rotating a .NET panel in Windows Forms

后端 未结 3 1661
死守一世寂寞
死守一世寂寞 2020-12-12 07:54

We use Windows Forms and custom user controls, and I would like to be able to rotate the panel hosting the userControl in a particular form. I have seen similar functionnali

3条回答
  •  时光说笑
    2020-12-12 08:10

    You can use rotations in GDI+ by calling the RotateTransform method on a Graphics object.

    However, rotating an entire control is not so simple, and will depend heavily on how the control is implemented.
    If it's a composite UserControl that has other controls inside of it, you're out of luck.
    If it's a sinlge control that paints itself, try inheriting the control, overriding the OnPaint method, and calling RotateTransform on the Graphics object. However, you will probably have trouble with it. In particular, you will probably need to override all of the mouse events and call the base control's events with rotated coordinates.

提交回复
热议问题