My collection disappears

  • Thread starter Thread starter Carlo \(MCP only\)
  • Start date Start date
C

Carlo \(MCP only\)

Good afternoon

I've developed some controls that holds specialized collections of items (a
collection of ImageItems for a ImageComboBox, a collection of MenuItems for
a Toolbar, etc.). The controls and the embedded collections interacts each
other correctly and everything work fine.
But I've a problem that I'm not able to solve: when the control
(ImageComboBox, for example) is placed on a form, and it is copied (Ctrl-C)
and then pasted into the same form, the embedded collection is correctly
copied into the new ImageComboBox.

Instead, when it is pasted into another form, the collection of items is
lost.

What I'm missing?

Thank you

Carlo
 
Ciao Carlo,

Il Tue, 13 Dec 2005 17:04:29 +0100 hai scritto :
Good afternoon
I've developed some controls that holds specialized collections of
items (a collection of ImageItems for a ImageComboBox, a collection of
MenuItems
for a Toolbar, etc.). The controls and the embedded collections interacts
each other correctly and everything work fine.
But I've a problem that I'm not able to solve: when the control
(ImageComboBox, for example) is placed on a form, and it is copied
(Ctrl-C) and then pasted into the same form, the embedded collection is
correctly copied into the new ImageComboBox.
Instead, when it is pasted into another form, the collection of items
is lost.
What I'm missing?

have you implemented a custom designer for your controls? if so be sure to
override the AssociatedComponents property in order to return an instance(s)
of the items you need to copy.

Here is simple implememtation:
public override ICollection AssociatedComponents
{
get
{
/*
MultiPage is CustomControl holding a "Page" control collection
*/
MultiPage mp = base.Component as MultiPage;
if( mp != null )
{
return mp.Pages;
}
return base.AssociatedComponents;
}
}

Being both italian, translating the answer:
Se hai implemetato un Custom Designer assicurati di fare l'override della
proprietà AssociatedComponents ritornando un'istanza dei controlli
contenuti.
Thank you

HTH,
Mauro Servienti
whynot [ at ] topics [ dot ] it
 
Hello Mauro
I have implemented a custom designer in all my controls collection, but I
missed an AssociatedComponents override.
Now I've implemented it and everithing works as needed! I simply return my
Item collection.
Thank you very much for your help,
sincerey
Carlo

----------------------------
Ciao Mauro
ho implementato un custom designer per ognuno dei controlli che sto
sviluppando, ma non avevo scritto nessun Override di AssociatedComponents.
Non è il primo controllo che scrivo che contiene una "custom collection", ma
mi era sfuggito il problema della copia, che ieri ho scoperto quasi
casualmente.
Adesso la copia funziona come deve!
Grazie mille per il tuo prezioso aiuto, e a presto.
Carlo



-------------------------------------------
Carlo, MCP (Windows Based Applications)
(e-mail address removed)


Mauro Servienti said:
Ciao Carlo,

Il Tue, 13 Dec 2005 17:04:29 +0100 hai scritto :
Good afternoon
I've developed some controls that holds specialized collections of
items (a collection of ImageItems for a ImageComboBox, a collection of
MenuItems
for a Toolbar, etc.). The controls and the embedded collections interacts
each other correctly and everything work fine.
But I've a problem that I'm not able to solve: when the control
(ImageComboBox, for example) is placed on a form, and it is copied
(Ctrl-C) and then pasted into the same form, the embedded collection is
correctly copied into the new ImageComboBox.
Instead, when it is pasted into another form, the collection of items
is lost.
What I'm missing?

have you implemented a custom designer for your controls? if so be sure to
override the AssociatedComponents property in order to return an
instance(s) of the items you need to copy.

Here is simple implememtation:
public override ICollection AssociatedComponents
{
get
{
/*
MultiPage is CustomControl holding a "Page" control collection
*/
MultiPage mp = base.Component as MultiPage;
if( mp != null )
{
return mp.Pages;
}
return base.AssociatedComponents;
}
}

Being both italian, translating the answer:
Se hai implemetato un Custom Designer assicurati di fare l'override della
proprietà AssociatedComponents ritornando un'istanza dei controlli
contenuti.
Thank you

HTH,
Mauro Servienti
whynot [ at ] topics [ dot ] it
 
Ciao Carlo,

Il Wed, 14 Dec 2005 08:59:30 +0100 hai scritto :
Hello Mauro
I have implemented a custom designer in all my controls collection, but
I missed an AssociatedComponents override.
Now I've implemented it and everithing works as needed! I simply return
my Item collection.
Thank you very much for your help,
sincerey
Carlo

You're welcome, see you next time!

Bye,
Mauro Servienti
whynot [ at ] topics [ dot ] it
 

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

Back
Top