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();

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.