I make a form in which it would be possible to turn the images that are in tabconrol. It seems to me that the problem is in the PictureBox array.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using MetroFramework.Components; using MetroFramework.Forms; namespace Image { public partial class MainForm : MetroForm { Rectangle screenSize = System.Windows.Forms.Screen.PrimaryScreen.Bounds; int logoOffset; int index; PictureBox[] ArrayofIMG; Bitmap temp; public MainForm() { InitializeComponent(); ArrayofIMG = new PictureBox[TabCTRL.TabPages.Count]; for (int i = 0; i < (int)TabCTRL.TabPages.Count; i++) { PictureBox a = new PictureBox(); ArrayofIMG[i] = a; Controls.Add(a); } logoOffset = this.Width - logo.Width; this.StyleManager = msmMain; } private void MainForm_Resize(object sender, EventArgs e) { logo.Width = this.Width - logoOffset; } private void left_Click(object sender, EventArgs e) { index = TabCTRL.SelectedIndex; rotate("left",index); } private void right_Click(object sender, EventArgs e) { index = TabCTRL.SelectedIndex; rotate("right",index); } void rotate(string side, int index) { if (ArrayofIMG[index].Image != null) { temp = new Bitmap(ArrayofIMG[index].Image); ArrayofIMG[index].Image.Dispose(); switch (side) { case "left": temp.RotateFlip(RotateFlipType.Rotate270FlipNone); break; case "right": temp.RotateFlip(RotateFlipType.Rotate90FlipNone); break; } ArrayofIMG[index].Image = temp; temp = null; } } } } 