Collection Editor
-
Hi, I want to create my control witch have collection (containing only
MyControlItem
objects) as a property. (Something likeImageList
with property calledImages
) And I want to use Collection Editor (in design mode click on "..."). But I don't know, how to change type of objects that are added (in Collection Editor) to the collection fromobject
toMyControlItem
. Thank you (and i'm sorry about my english) Tomáš Petříček -
Hi, I want to create my control witch have collection (containing only
MyControlItem
objects) as a property. (Something likeImageList
with property calledImages
) And I want to use Collection Editor (in design mode click on "..."). But I don't know, how to change type of objects that are added (in Collection Editor) to the collection fromobject
toMyControlItem
. Thank you (and i'm sorry about my english) Tomáš Petříček -
http://www.codeproject.com/script/comments/forums.asp?msg=291230&forumid=1649#xx291230xx[^] Wow, 36 hours before you even thought about it :laugh: Cheers Give them a chance! Do it for the kittens, dear God, the kittens!
:-O Thank you
-
http://www.codeproject.com/script/comments/forums.asp?msg=291230&forumid=1649#xx291230xx[^] Wow, 36 hours before you even thought about it :laugh: Cheers Give them a chance! Do it for the kittens, dear God, the kittens!
:confused: I don't know how to do this What's wrong with this:
public class DropDownItem { private string szName=""; public DropDownItem() { szName="DropDownItem1"; } public string Name { get { return szName; } set { szName=value; } } } public class DropDownCollection : CollectionBase { public DropDownCollection() { } public virtual void Add(DropDownItem val) { this.List.Add(val); } }
Have you got some sample source or link ? Thank you -
:confused: I don't know how to do this What's wrong with this:
public class DropDownItem { private string szName=""; public DropDownItem() { szName="DropDownItem1"; } public string Name { get { return szName; } set { szName=value; } } } public class DropDownCollection : CollectionBase { public DropDownCollection() { } public virtual void Add(DropDownItem val) { this.List.Add(val); } }
Have you got some sample source or link ? Thank youHi Everything seems fine :) But (isnt there allways a butt?) you may need to add some extra methods to implement. Also, implement the collection in your class as follows:
public class MyClass
{
DropDownCollection ddcol;public MyClass()
{
ddcol = new DropDownCollection();
}public DropDownCollection DropDownItems
{ get { return ddcol;} } //note, NO set property
}Nave a look at this as well, very handy for creating Strongly typed collections :) http://www.gotdotnet.com/userfiles/kristopher_johnson/TypedCollectionGenerator_1_3_0.zip[^] Hope it works this time :) Give them a chance! Do it for the kittens, dear God, the kittens!
-
Hi Everything seems fine :) But (isnt there allways a butt?) you may need to add some extra methods to implement. Also, implement the collection in your class as follows:
public class MyClass
{
DropDownCollection ddcol;public MyClass()
{
ddcol = new DropDownCollection();
}public DropDownCollection DropDownItems
{ get { return ddcol;} } //note, NO set property
}Nave a look at this as well, very handy for creating Strongly typed collections :) http://www.gotdotnet.com/userfiles/kristopher_johnson/TypedCollectionGenerator_1_3_0.zip[^] Hope it works this time :) Give them a chance! Do it for the kittens, dear God, the kittens!
Huh, it works now :) but I don't know why it doesn't works as I wrote but i have downloaded TypedCollectionGenerator and with this collection it works ;P (This link is better) http://kristopherjohnson.net/TypedCollectionGenerator/1.3.0/TypedCollectionGenerator_1_3_0.zip[^] Thank for your help Tomas
-
Huh, it works now :) but I don't know why it doesn't works as I wrote but i have downloaded TypedCollectionGenerator and with this collection it works ;P (This link is better) http://kristopherjohnson.net/TypedCollectionGenerator/1.3.0/TypedCollectionGenerator_1_3_0.zip[^] Thank for your help Tomas
Tomas Petricek wrote: but I don't know why I was thinking about this. Perhaps it needs the indexer or the GetValueAt() functions implemented. OK I looked at the CollectionEditor's docs: Notes to Inheritors: This editor can edit collections that have an Item property. The editor can determine the type of the collection from the Item property, if it exists. If the collection does not have this property, or if you want to provide collections of more than one type, you can override certain protected members of this class to customize the editor to support other types of collections. Cheers :) Give them a chance! Do it for the kittens, dear God, the kittens!
-
Tomas Petricek wrote: but I don't know why I was thinking about this. Perhaps it needs the indexer or the GetValueAt() functions implemented. OK I looked at the CollectionEditor's docs: Notes to Inheritors: This editor can edit collections that have an Item property. The editor can determine the type of the collection from the Item property, if it exists. If the collection does not have this property, or if you want to provide collections of more than one type, you can override certain protected members of this class to customize the editor to support other types of collections. Cheers :) Give them a chance! Do it for the kittens, dear God, the kittens!
That's it :rolleyes: