A
A. Haeser
Hello,
I have build a little application with dynamic usercontrols on a panel.
Sometimes there are 5 userscontrols on the panel, sometimes much more.
It is database driven, everey usercontrol needs to get details from
database.
I've tried to cache some panels in a collection using a key. This gives
me more performance because about of 25 keys will be used randomely.
Here a little indication of the code:
dim col as new collection 'my panels - cache
'On the form I've the mainpanel:
protected withevents mainpanel as new System.windows.forms.panel
private sub createPanel(byval key as string)
dim panel1 as new System.windows.forms.panel
try
mainpanel = col.item("thekey")
return 'yes, success from cache!
catch
'no item in cache
end try
... 'add controls to panel1
... 'add more controls to panel1
'Add this item to cache
col.add("thekey", panel1)
mainpanel = panel1
end sub
-----------------------------------------------------------
Question / problem itself:
Why doesn't this work, when showing a cached panel I see no controls
on the panel! The controls had a reference to nothing? How can I solve
this?
(I've tried to do the same with caching a array of all controls on the
panel, that works fine)
I have build a little application with dynamic usercontrols on a panel.
Sometimes there are 5 userscontrols on the panel, sometimes much more.
It is database driven, everey usercontrol needs to get details from
database.
I've tried to cache some panels in a collection using a key. This gives
me more performance because about of 25 keys will be used randomely.
Here a little indication of the code:
dim col as new collection 'my panels - cache
'On the form I've the mainpanel:
protected withevents mainpanel as new System.windows.forms.panel
private sub createPanel(byval key as string)
dim panel1 as new System.windows.forms.panel
try
mainpanel = col.item("thekey")
return 'yes, success from cache!
catch
'no item in cache
end try
... 'add controls to panel1
... 'add more controls to panel1
'Add this item to cache
col.add("thekey", panel1)
mainpanel = panel1
end sub
-----------------------------------------------------------
Question / problem itself:
Why doesn't this work, when showing a cached panel I see no controls
on the panel! The controls had a reference to nothing? How can I solve
this?
(I've tried to do the same with caching a array of all controls on the
panel, that works fine)