Hello...
I've written a small program to learn the means of rotating images. I have four buttons, each with it's own image. The images on the first three buttons work fine, but the fourth button rotates by 180 degrees.
I'm programming to keep my brain ticking over and using vb 2008
I'd appreciate if someone could provide a solution :o)
Here is the code
Imports System.Drawing
Public Class Form1
Dim WithEvents oneButton As Button = Nothing
Dim btnList = New List(Of Button)
'Declare button variables
Dim btnSize As Integer = 80
Dim btnX As Integer = 90
Dim btnY As Integer = 30
Dim xOffset As Integer = 60
Dim btnCount As Integer = 4
Dim bitmap As Bitmap = Nothing
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Size = New Size(480, 180)
MakeButtons()
End Sub
Private Sub MakeButtons()
For i As Integer = 0 To btnCount - 1
oneButton = New Button() 'Initialise button
oneButton.Size = New Size(btnSize, btnSize)
Select Case i
Case 0
oneButton.Image = My.Resources.btn1
Case 1
oneButton.Image = My.Resources.btn2
Case 2
oneButton.Image = My.Resources.btn3
Case 3
oneButton.Image = My.Resources.btn4
End Select
oneButton.Location = New Point((btnX * i) + xOffset, btnY)
oneButton.FlatStyle = FlatStyle.Standard
Me.Controls.Add(oneButton) 'Add oneButton
AddHandler oneButton.Click, AddressOf RotateButton_Click 'Add handler to rotate image
btnList.Add(oneButton) 'Add button to list
Next
End Sub
Private Sub RotateButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles oneButton.Click
bitmap = sender.Image
bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone)
End Sub
End Class