Upper (reasonable) limit on the number of user control instances

I have a menu that used to be a treeview control, but now I want to make each element more visual and add additional information to each object in the tree.

My first intention was to create a user control representing the element and add it to the panel at runtime. Is this a good approach? Sometimes there can be more than a hundred items. I know that there is a maximum number of controls that you can theoretically have in form, but this is not my main problem. My concern is mainly about performance.

Another approach that I was thinking about is to make a list and do the extra stuff in the onPaint method. But it seems a little unstable and too complicated to maintain.

Any thoughts?


EDIT:

I tested the user approach by adding 200 user elements to the att form_Load panel and it takes quite a while to actually add, but there seems to be no other performance issues. Scrolling works fine, and I made each user control expandable, and this property does not linger in any case, even when there are about a hundred and a hundred under it on the panel.

But still ... Am I here at all a track?

+3
source share
1 answer

UserControls "" , System.Windows.Forms.Control, Win32. , , ..

Windows "" . 200 UserControls, 200 "", . "" , , ScrollBar OnPaint, .

, , ListBox TreeView.

, Windows , , . , , " ". Cribbing from :

ListBox. ctor OwnerDrawVariable OnDrawItem OnMeasureItem.

, , , .

+6

Source: https://habr.com/ru/post/1708144/


All Articles