Hello!!
I have created my own collection :
[TypeConverter(t ypeof(MyCollect ionConverter))]
public class MyCollection
{
private Color color1 = Color.White;
private Color color2 = Color.Black;
private int value1 = 0;
private int value2 = 0;
private bool blink = false;
private bool visible = true;
private string nname = string.Empty;
[Browsable(true)]
public Color Color1
{
get { return color1; }
set { color1 = value; }
}
[Browsable(true)]
public Color Color2
{
get { return color2; }
set { color2 = value; }
}
[Browsable(true)]
public int Value1
{
get { return value1; }
set { value1 = value; }
}
[Browsable(true)]
public int Value2
{
get { return value2; }
set { value2 = value; }
}
[Browsable(true)]
public bool Blink
{
get { return blink; }
set { blink = value; }
}
[Browsable(true)]
public bool Visible
{
get { return visible; }
set { visible = value; }
}
[Browsable(true)]
public string Name
{
get { return name; }
set { name = value; }
}
public MyCollection()
{
}
}
public class MyCollectionCon verter : CollectionBase
{
public MyCollectionCon verter ()
{
}
public int Add(MyCollectio ne)
{
return this.InnerList. Add(e);
}
public void AddRange(MyColl ection[] es)
{
this.InnerList. AddRange(es);
}
public void Remove(MyCollec tione)
{
InnerList.Remov e(e);
}
public new void RemoveAt(int index)
{
InnerList.Remov eAt(index);
}
public bool Contains(MyColl ection e)
{
return InnerList.Conta ins(e);
}
public MyCollection this[int index]
{
get { return (MyCollection)t his.InnerList[index]; }
set { this.InnerList[index] = value; }
}
}
and in a click event i add some elements to the collection like this:
MyCollectionCon verter myCollectionCon verter = new MyCollectionCon verter
();
for ( int i = 0; i < 5; i++ )
{
MyCollection myCollection = new MyCollection();
myCollection.Na me = "Element " + i.ToString();
myCollectionCon verter.Add(myCo llection);
}
and then i show myCollectionCon verter in a PropertyGrid, when i open the
Collection editor i can see all the elements.
My question is how can i disable the add and remove buttons in the
Collection editor this because i don't want that a user can add more
elements.
This is possible?
Somebody know how can i do that?
Regards,
Alberto Martinez
*** Sent via Developersdex
http://www.developersdex.com ***