Hello!
I have stucked on thes for few days already. My difference from examples is that I`m adding events to Paint dinamically. I`m not professional so I haven`t figured out how to redesign my code.
This is my code:
foreach(Part part in product.Parts)
{
TabPage tabPage = new TabPage(part.FixedCode);
tabPage.Name = part.FixedCode;
tabPage.Size = tabPartCollection.Size;
tabPage.Text = part.Name;
DrawOnTabPage drawOnTabPage = new DrawOnTabPage();
drawOnTabPage.LoadPart(part, product.MaxPartLength);
tabPage.Paint += new PaintEventHandler(drawOnTabPage.Draw);
tabPartCollection.Controls.Add(tabPage);
}
This foreach is called when pressing a form button. Class DrawOnTabPage contains method Draw which draws image on current TabPage. Everything works fine but when I move form outside my display it hungs up. The same is happening when I drag any other window over my application. CPU is 100% and this form takes all of it. As I understand there is redraw function called in this case. I have tried everything, disposing objects everywhere, setting specific styles but problem remains. Please help me!
Loading

Answers
Know the answer? Post it. Somebody with the same question will find it here.