PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms My collection disappears

Reply

My collection disappears

 
Thread Tools Rate Thread
Old 13-12-2005, 04:04 PM   #1
Carlo \(MCP only\)
Guest
 
Posts: n/a
Default My collection disappears


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




-------------------------------------------
Carlo, MCP (Windows Based Applications)
carlodevREMOVE@gmail.com



  Reply With Quote
Old 13-12-2005, 04:19 PM   #2
Mauro Servienti
Guest
 
Posts: n/a
Default Re: My collection disappears

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


> Carlo


HTH,
Mauro Servienti
whynot [ at ] topics [ dot ] it
--
"...voi abili a tenere sempre un piede qua e uno là avrete un avvenire certo
in questo mondo qua però la dignità dove l'avete persa?..."
"Vasco Rossi - Gli Spari Sopra (1993)"


  Reply With Quote
Old 14-12-2005, 07:59 AM   #3
Carlo \(MCP only\)
Guest
 
Posts: n/a
Default Re: My collection disappears

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)
carlodevREMOVE@gmail.com


"Mauro Servienti" <mauroservienti@online.nospam> ha scritto nel messaggio
news:uLM%23dEAAGHA.3864@TK2MSFTNGP12.phx.gbl...
> 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

>
>> Carlo

>
> HTH,
> Mauro Servienti
> whynot [ at ] topics [ dot ] it
> --
> "...voi abili a tenere sempre un piede qua e uno là avrete un avvenire
> certo in questo mondo qua però la dignità dove l'avete persa?..."
> "Vasco Rossi - Gli Spari Sopra (1993)"
>



  Reply With Quote
Old 14-12-2005, 08:19 AM   #4
Mauro Servienti
Guest
 
Posts: n/a
Default Re: My collection disappears

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
--
"...voi abili a tenere sempre un piede qua e uno là avrete un avvenire certo
in questo mondo qua però la dignità dove l'avete persa?..."
"Vasco Rossi - Gli Spari Sopra (1993)"


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off