Thanks a lot for the reply azerty but I am well aware of the said method and
"azerty" <azerty@aaaa.fr> wrote in message
news:Ox0TqTfGFHA.2524@TK2MSFTNGP15.phx.gbl...
> I am not sure if this point can help your (i don't understand very well
your
> scenariio)
>
> but When you want create or destroy a component in design mode you must
use
> the IDesignerHost.CreateComponent or IDesignerHost.DestroyComponent
method.
>
> example of code :
>
> protected override DataGridItemExtenderBase NewItem(DataGrid dataGrid,
> DataGridItemExtenderBase item)
> {
> DataGridColumnExtender result;
> #if DESIGN
> System.ComponentModel.Design.IDesignerHost dh =
> dataGrid.GetDesignerHost();
> if (dh != null)
> {
> result =
>
(DataGridColumnExtender)dh.CreateComponent(typeof(DataGridColumnExtender));
> result.MappingName = item.MappingName;
> }
> else
> #endif
> result = new DataGridColumnExtender((DataGridColumnExtender)item);
>
> return result;
>
>
> "joeycalisay" <hcalisay@_spamkiller_codex-systems.com> a écrit dans le
> message de news:uVGLWhXGFHA.464@TK2MSFTNGP15.phx.gbl...
> > I have a custom enum property Parts for my custom containercontrol
> declared
> > as below:
> >
> > [Flags]
> > public enum Parts : int
> > {
> > None = 0,
> > Header = 1,
> > HeaderDetail = 3,
> > HeaderFooter = 5,
> > HeaderDetailFooter = 7
> > }
> >
> > Depending on the Parts configuration chosen at designtime, I will be
> > creating/destroying the associated components (Header, Detail or
Footer).
> As
> > such, I am just attaching a custom eventhandler on the property set
method
> > since it is logical that the whole implementation is associated with the
> > property change.
> >
> > The problem is with regard to the undo/redo feature of VS. For example,
> when
> > I changed from HeaderFooter to Header, the Footer component is removed
> from
> > my custom containercontrol and destroyed from the form surface through
the
> > designerhost after the property set. When I Redo the property change, VS
> > tries to recreate the destroyed component since it was part of the
> property
> > change transaction then after that comes the property change which has
my
> > handler to create a Footer component and then add it to my
> containercontrol.
> > The additional component gets created in the form and gets code gen'ed
> which
> > basically has no function since it was not added to any control
> collection.
> >
> > I need some views perhaps there is wrong with my design. Is it possible
to
> > have a check in the end so I can destroy again the dummy components
> created
> > by undo? But then this will be costly and not ideal. Or perhaps I just
> > disable the undo/redo feature for the said property change? Please
help...
> >
> > --
> > Joey Calisay
> >
http://spaces.msn.com/members/joeycalisay/ > >
> >
> >
>
>