Custom control loading order

D

devtotal

Hi, I have a custom control which loads data, with some critera from a
property of the hosting UserControl.

I try to get the property value on BindingChanged in my custom control,
but, at that time, host UserControl is not completly loaded, so my
property is NULL.

I can't call a custom control's method from host UserControl. It would
'destroy' the automatic behaviour...

How can I know in my custome control that the host UserControl has
finished to load ?

TIA
 
J

John Saunders [MVP]

Hi, I have a custom control which loads data, with some critera from a
property of the hosting UserControl.

I try to get the property value on BindingChanged in my custom control,
but, at that time, host UserControl is not completly loaded, so my
property is NULL.

I can't call a custom control's method from host UserControl. It would
'destroy' the automatic behaviour...

How can I know in my custome control that the host UserControl has
finished to load ?

Instead of having the custom control grab a property of the hosting control,
why not have the hosting control set a property of the custom control?
 
D

devtotal

Because, I can have up to 15 custom controls of diferent types using the
UserControl's value in 40 UserControls...

I could loop for my custom control type, and set the value in each ot
the UserControls , but it's a lot more code, and i want it to be as
readible as possible...

So, I only wonder if the custom control has a 'Framework' way to know
that the host UserControl is loaded...


John Saunders [MVP] a écrit :
 
J

John Saunders [MVP]

Because, I can have up to 15 custom controls of diferent types using the
UserControl's value in 40 UserControls...

Well, I don't have much more to offer, other than the observation that your
design seems to be too tightly-coupled.

Perhaps your custom controls could implement some particular interface. Your
user controls could then recursively search their Controls collection for
controls which implement this interface. You could even move this code into
a common base class for the user controls.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top