I’ve created a simple program and now i’m in the stages of doing my designing. I’ve got a multiple Panels which i make visible / invisible to switch between “tabs” (EG. 1 panel for the login screen and 1 panel for the create account screen). Now i’ve made these panels invisible because i want them just as containers to be able to quickly move around controls and create buttons in.
My problem is that i’ve set my forms background image to a image i made in photoshop and whenever i switch between panels it flickers, whenever i just use a system color (white,black) this doesn’t happen.
Is there any way for me to remove the flickering?
i’ve tried :
- Setting double buffer to true
- protected overrideing OnPaint, CreateBackground, and Createparam
my code is extremely basic :
private void btnNewAcc_Click(object sender, EventArgs e)
{
PanelNewAccount.Visible = true;
PanelLogin.Visible = false;
}
4
Answers
Thanks to Patrick i've solved my problem, instead of using panels i'm using a TabControl and i assigned the same background to each tab. Just as easy to add dynamic buttons as well. Same features as panels but without the flickering.
Try to setting the form property DoubleBuffered to true, in winforms the flickering usually happens because the GDI+ is trying to draw the control(s) a lot of times so DoubleBuffering you graphics should help in such cases
Even though i am late but if somebody else is also suffering from the same problem then this code fixed the flickering for me even though i dont know how it works.
I found it here.
Add the above code snippet in your program and in the contructor of your app add this line:
code copy from codeproject solved my problem.