0

Hey guys,

I am writing a board game to teach myself c#.

I have made a custom control for the board tiles, this is made up of label and picturebox.

So I want to be able to rotate my custom controls when i draw them so that they face the correct direction, as you would in monopoly, trivial persuit etc.

I have been looking for ages but can't find any way of doing it.

I know I can use the following for shapes and strings but can't figure out how to rotate a custom control. Anyone got any pointers? Thanks

Graphics g = new Graphics()
g.TranslateTransform(10, 10);
g.RotateTransform(45);
g.DrawString("this is a string", this.Font, Brushes.Black, 15, 15);
g.ResetTransform();
2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by nick.crane
1

If you only have a PictureBox and Label on your custom control then consider removing them and painting the image and text manually using the graphics object in the OnPaint event for the control.

Then you will have complete control of the image on the control and can rotate it using the trasforms.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.