PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
My collection disappears
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
My collection disappears
![]() |
My collection disappears |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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)" |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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)" > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
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)" |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

