Re: Collection, collectioneditor and constructor

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Isn't your Add method going to create the new instance and then return
it? If so, then just call the constructor to the Row class which will take
the height. Mark the constructor as internal, so that classes outside of
your assembly can't access it.

For this to work though, your Add method can't allow an existing
instance to be passed to the method, it has to take properties which you
then use to create the instance, and then add that to the collection.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx



"R.A.F." <noemail@xxxxxxxxxx> wrote in message
news:Ob0svnOEIHA.3712@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

I'm still having my issue with my collection.
I remind you the facts :
- I have a class called "Row".
- I have a collectionbase class named "RowsCollection"
- I have a collectionEditor class called "RowsCollectionEditor".

When i add a new row into the collection class, my new row should have its
property Height, setup to default value = 20. This default value for row
height is written as private static readonly into my RowsCollection class.

I know that Row constructor should allow such parameter like :
public Row(RowsCollection owner, int iHeight)
{
...
this.Height = iHeight
...
}

But my problem is that i do not understand from where should i call this
constructor.

1. Should i call it from RowsCollection method ? if yes, from which one
and how ?
2. Should i call it from RowsCollectionEditor method ? if yes, from which
one and how ?

i tried to find something about createnewinstance from
RowsCOllectionEditor or Add method (overriden) from RowsCollection but
nothing works...

So i'm confused. :-(

Any help would be wonderfull,
thx,

RAF


.



Relevant Pages

  • Re: Collection property and control owner
    ... You would have to declare a constructor that takes the height, and then pass the value to the constructor when the instance is created. ... I have a custom control in which i have a property called "RowsCollection". ... This property is a CollectionBase class. ...
    (microsoft.public.dotnet.languages.csharp)
  • Collection, collectioneditor and constructor
    ... I have a collectionbase class named "RowsCollection" ... This default value for row height is written as private static readonly into my RowsCollection class. ... public Row(RowsCollection owner, int iHeight) ... Should i call it from RowsCollection method? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Collection, collectioneditor and constructor
    ... thx...this works well as command line, but it does not solve my issue if end user works with the property editor :-( ... I have a collectionbase class named "RowsCollection" ... This default value for row height is written as private static readonly into my RowsCollection class. ... Should i call it from RowsCollection method? ...
    (microsoft.public.dotnet.languages.csharp)
  • Collection property and control owner
    ... I have a custom control in which i have a property called "RowsCollection". ... This property is a CollectionBase class. ... How can i do to pass such default value to each row, only during row creation? ...
    (microsoft.public.dotnet.languages.csharp)