Take the 2-minute tour ×

Using Microsoft Visual C#

I am making a Custom Control that has a list of Rectangles I am creating the List like this

private List<Rectangle> _Rect = new List<Rectangle>();
public List<Rectangle> Rect { get { return _Rect; } set { _Rect = value; } }

In design mode when I add the Control to a form I cannot change the list. in the properties window, I click on Rect which has a collection box. the box opens allowing me to add new Rectangles, but where the properties of the rectangle are it says "Object does not match the target type"

It does work if I add a Rectangle as oppossed to a List. And more complex properties work, ei. A list of custom class.

Any Ideas?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I believe this has to do with how the RectangleConverter exposes a Rectangle for manipulation in the PropertyGrid. For example, see the Bounds property on your control or form. You can bypass this by creating a new Rectangle class that doesn't use the same TypeConverter, or you can switch to RectangleF, which does not use the RectangleConverter.

share|improve this answer
RectangleF solved my problems thanks alot. It was the simpliest solution I could have hoped for. –  K'Leg Dec 12 '11 at 21:14
add comment

Your Answer


