Home All Groups Group Topic Archive Search About
Author
7 Aug 2006 6:48 AM
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)

Author
7 Aug 2006 8:45 AM
Cor Ligthert [MVP]
A,

Are you familiar with the debug possibilities in Visual Studio Net?

Cor

Show quoteHide quote
"A. Haeser" <a*@ttt.nl> schreef in bericht
news:1154933335.104567.283060@m79g2000cwm.googlegroups.com...
> 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)
>
Author
7 Aug 2006 9:56 AM
A. Haeser
Yes, I'm familiar with it.

Cor Ligthert [MVP] schreef:

Show quoteHide quote
> A,
>
> Are you familiar with the debug possibilities in Visual Studio Net?
>
> Cor
>
> "A. Haeser" <a*@ttt.nl> schreef in bericht
> news:1154933335.104567.283060@m79g2000cwm.googlegroups.com...
> > 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)
> >
Author
7 Aug 2006 10:08 AM
Cor Ligthert [MVP]
> Yes, I'm familiar with it.
>
And did you try it, because the error should be somewhere in your code, now
you show the begin and the end but how can we see where the error is?

Cor


Show quoteHide quote
> Cor Ligthert [MVP] schreef:
>
>> A,
>>
>> Are you familiar with the debug possibilities in Visual Studio Net?
>>
>> Cor
>>
>> "A. Haeser" <a*@ttt.nl> schreef in bericht
>> news:1154933335.104567.283060@m79g2000cwm.googlegroups.com...
>> > 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)
>> >
>
Author
7 Aug 2006 11:55 AM
A. Haeser
There is no error, but the panel, loaded from cache will not have /
show the dynamic added controls!



A. Haeser schreef:

Show quoteHide quote
> 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)