dynamic windows form

  • Thread starter Thread starter BillE
  • Start date Start date
B

BillE

vb.net, visual studio 2005, windows forms

My application dynamically creates controls and adds them to a panel on a
form. This is done in the form load event.

I don't know if I would call it flickering, but parts of some controls get
displayed before others. They don't exactly flicker, they just appear in
pieces, instead of all at once. The controls include nested panels. I have
tried to avoid TableLayoutPanels because the performance is so terrible.

Before I add the controls, I suspend layout for the form and the panel. The
form is double-buffered.

I also tried setting the panel.visible = false and then true when the
contols were all created and added to the panel, but it doesn't help.

It looks funky while the page is loading, although it loads fast so its not
too bad.

I would like to fix this, and I would appreciate any suggestions.

Thanks
Bill
 
What if you do that in the constructor ? Add a sub new in your code and the
designer should show :
Sub New()

' This call is required by the Windows Form Designer.

InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub



You can then call your own InitializeComponet method to build your dynamic
controls...
 
My application dynamically creates controls and adds them to a panel on a
form. This is done in the form load event.

I don't know if I would call it flickering, but parts of some controls get
displayed before others. They don't exactly flicker, they just appear in
pieces, instead of all at once. The controls include nested panels. I have
tried to avoid TableLayoutPanels because the performance is so terrible.

Before I add the controls, I suspend layout for the form and the panel. The
form is double-buffered.

I also tried setting the panel.visible = false and then true when the
contols were all created and added to the panel, but it doesn't help.

It looks funky while the page is loading, although it loads fast so its not
too bad.

I would like to fix this, and I would appreciate any suggestions.

In a similar setting, I have a form with an empty TabControl. In the form's
load event, I add several panels, and on each panel I add about 20 controls.
I get a good draw by setting the form.visible to false at the beginning of
the form load event, and true at the bottom.

IMO, the flicker you are experiencing comes from more than one drawing
operation being performed in rapid succession. There is at least one draw
because of what you are doing in the load event, and later there is another
draw caused by .net/windows. The way to stop this is to run the load event
with the form's visible set to false.
 
Thanks, that works when the form first loads.
However, the form can be reloaded with different controls, and Sub New won't
fire then. Sorry, I should have mentioned that.

Thanks
Bill
 
Back
Top