views:

60

answers:

2

Hi guys

I'm being overly simplistic here, but say I have a WinForm with several controls on it (for example: a textbox, a treeview and a listview).

To ensure the smoothest possible experience for the future (for instance, that listview may one day hold a lot of data), what should be done at the start?

My knowledge of this kind of thing is very limited, but I'm assuming double buffering is advised? I've also heard something about overriding the OnPaint method for some controls?

Thanks Zach

+2  A: 

When designing new applications you don't have to think about this stuff. In case you run into problems later, a fix can be applied without destroying the work you have already put into the project. Although I can assure you that 95% of the applications don't need any special optimizations regarding controls or painting of controls, especially not in OnPaint. Good luck.

testalino
Thanks for the advice. I only ask because the last application I created resulted in a lot of trouble due to some flickering of my User Controls. Also, resizing columns of a listview was incredibly sluggish, and so I wanted to make sure I got all of this stuff sorted out before the actual 'coding' began.
Zach Whitfield
Yeah, some controls like the ListView need a minor fix, because they have flickering issues. But that shouldn't concern you in your current phase. There is also an issue with the list view when settings hundreds of items at a time, but that can be addressed as well.
testalino
A: 

To ensure the smoothest possible experience for the future (for instance, that listview may one day hold a lot of data), what should be done at the start?

1- If it is going to store a huge data , try to implement pagination for the data.

2- You are using treeview , don't try to load whole tree in memory. Use On demand Loading of tree i.e. only show the root nodes and when user click to expand a node only then load data.

3- If your application provides a functionality of searching nodes in tree than try to remember that tree is a special kind of graph so use proper graph algorithms like (DFS , BFS) to search the node.

4- Try to move operations which consumes lot of time in the background worker component , it supoorts event based notification which helps you to report progress of your operations.

5- Try to use caching of non frequetly changed data , that menas if suppose , you are having a winforms which shows a dripdown list of countries so just pick the data once and store it in memory so that , you won't need a new database call every time when you need that data.

this is very initial steps but there can be lot of other also like using WeakRefernce class for your tree view.

Try to read performance optimization at MSDN.

saurabh