Custom user control - generate code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lut

    #1

    Custom user control - generate code

    Hey,

    I made a custom usercontrol (Custom listview) in the
    Control Library.

    Now I want in the properties of design a property 'Sort'.
    (That is not a problem to do that) But, when it is Yes
    then I want to add following code in my class.

    private ListViewSortMan ager SortMgr1;

    and in the InitialiseCompo nent
    this.SortMgr1 = new ListViewSortMan ager(......);

    How can I generate this code when I choose in the design
    time sort = yes

    Thanks,
    Lut

  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Custom user control - generate code

    Lut,

    I think that what you will have to do is create a custom designer for
    the Sort property. When the sort property is set to true, you would then
    also set the SortMgr1 property to an instance of the class that you create.
    However, I don't think you will be able to use the constructor like that.
    If anything, you will have to create a new instance of the class (default
    instance), and then set the properties on the instance (kind of like a
    collection editor works).

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nick(dot)paldin o=at=exisconsul ting<dot>com

    "Lut" <newsgroup.emai l@pandora.be> wrote in message
    news:24a4a01c38 d0a$92e77ea0$a6 01280a@phx.gbl. ..[color=blue]
    > Hey,
    >
    > I made a custom usercontrol (Custom listview) in the
    > Control Library.
    >
    > Now I want in the properties of design a property 'Sort'.
    > (That is not a problem to do that) But, when it is Yes
    > then I want to add following code in my class.
    >
    > private ListViewSortMan ager SortMgr1;
    >
    > and in the InitialiseCompo nent
    > this.SortMgr1 = new ListViewSortMan ager(......);
    >
    > How can I generate this code when I choose in the design
    > time sort = yes
    >
    > Thanks,
    > Lut
    >[/color]


    Comment

    Working...