C# -User Control flickers when added to form

May 21, 2011 at 11:15:07
Specs: Windows 7
I'm working on a small project in college, and I'm doing a Windows Application.
I work with one main form, a menustrip, and a lot of user controls which are added to the form from the menustrip's click functions like this : this.Controls.Add(...);
My huge problem is the flickering.
Now my form has a custom background, and the user controls have custom semi-transparent backgrounds themselves.
I searched the net, and found a lot of sites and forums where people solve their similar problem with double buffering. I tried that too, but it doesn't work for me. Either I don't know how to implement it right or there is another way. Can someone help me out please?

See More: C# -User Control flickers when added to form

Report •

#1
Report •

#2
May 22, 2011 at 12:46:32
Doesn't work :(

Report •

#3
May 22, 2011 at 16:09:17
Doesn't work :( isn't helpful. Showing your code is.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
May 23, 2011 at 04:00:12
I know it isn't helpful, but I thought this is a typical problem.
This is a typical user control of mine:
namespace Byblos
{
public partial class ujfelhasz : UserControl
{
ResourceManager rm;

public ujfelhasz()
{
InitializeComponent();
}

public void LoadRes() {
rm = new ResourceManager("Byblos.Res", Assembly.GetExecutingAssembly());
label1.Text = rm.GetString("csoport");
label2.Text = rm.GetString("vezetekn");
label3.Text = rm.GetString("keresztn");
label4.Text = rm.GetString("cim");
label5.Text = rm.GetString("telszam");
label6.Text = rm.GetString("szemszam");
label7.Text = rm.GetString("igszam");
label8.Text = rm.GetString("anyan");
label9.Text = rm.GetString("apan");
label10.Text = rm.GetString("szemszam");
label11.Text = rm.GetString("igszam");
label12.Text = rm.GetString("jelszo");
label13.Text=rm.GetString("jelszomeg");
button1.Text = rm.GetString("hozzaad");
groupBox1.Text = rm.GetString("felhaszadat");
groupBox2.Text = rm.GetString("szgy");
groupBox3.Text = rm.GetString("letfel");
groupBox4.Text = rm.GetString("ujfelhaszjelszo");
radioButton1.Text = rm.GetString("szemelyin");
radioButton2.Text = rm.GetString("szemelyivel");

}
private void ujfelhasz_Load(object sender, EventArgs e)
{
LoadRes();

}

}
}

And this is how I add it to the form:


private void újFelhasználóToolStripMenuItem_Click(object sender, EventArgs e)
{

cont.Dispose();
ujfelhasz ujfelhasz = new ujfelhasz();
// a user control kozepre helyezese
int xpos = (this.Width - ujfelhasz.Width) / 2;
int ypos = (this.Height - ujfelhasz.Height) / 2;
ujfelhasz.Location = new Point(xpos, ypos);
cont = ujfelhasz;
this.Controls.Add(ujfelhasz);

}

Can it be solved or should I restart and make it a WPF instead.


Report •

#5
May 31, 2011 at 06:13:47
I'm still not entirely sure what your problem is. Do you want it to just not paint while you're adding controls? If that's the case, just disable painting.

How To Ask Questions The Smart Way


Report •

Ask Question