ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Adding controls smoothly...

(1/2) > >>

.Beatz:
Okay so I am writing a program that has to load a lot of information from MySql then add it to controls.

Get Data > Fill Control > Display Control

Only problem is I could be loading as few as 4 controls or as many as 1000. Is there a better way I can add everything? It works for now but is not pleasant to watch and would defiantly not be good for a consumer to see. I have tried loading the controls before the form is loaded but that didn't work so well, also tried Control.SuspendLayout(); and Control.ResumeLayout(); Still no good.

If anyone has any ideas I will be will to try anything to get this working 100%

Many thanks

*Edit* Forgot to mention I am programming on C#

Renegade:
Well, it depends on what control that you are loading to a large degree.

If you seriously want to dive into the VERY deep end, I recommend buying the Infralution Virtual Tree control as it does dynamic loading, and could give you some insight into how to do what you're asking.

However, if you're loading 1000 controls, I think you have a very serious design flaw. Why would you want to do that? I really have no idea what you're trying to accomplish, so without more details, I'm afraid that I can't be of much help.

Still, if you want to do it like that...

Do it in threads. Have an update that lets the user know what's going on. Create all the controls. Fill them. Return them. Add them to the UI in a Panel control (or whatever - I'm assuming a Panel is best there). Return control of the application to the user when it's finished or they click a "Cancel" button or a "Stop" button. (I'd use "Stop" to mean "that's enough for now".)

If you can post more details, maybe I or someone else can chime in with some better information. Until then, look into threading as that will likely solve your problems.

.Beatz:
Well not literally 1000 but it has no limit on the amount... I would say generally about 20-30 controls... I will look into threading though.

[Header]
{info}
{info}
[Header]
{info}

Header is not a problem since it is just the Header and doesn't really load any info

Info loads info from 1 row and about 5 columns from MySql for each (2 picture boxes, 3 linklabels, 3 labels)

fenixproductions:
I had investigated such issue long ago and there was no solution for multi-control forms. SuspedLayout is the most popular/answered one but it does not help too much.
There is also double buffering solution which also has some troubles.

The only thing which helped (from user perspective) was to "make screen busy"  - according to an advice from MS site I read very long ago.
So… build eveything in background and show waiting animation during that.

Ath:
Use the databinding features of .NET, it will lazy-load by default (afaik) when loading lots of controls, and it'll fetch & display 'Just In Time', when using controls like comboboxes etc. Using WPF for the UI might help too.

Navigation

[0] Message Index

[#] Next page

Go to full version