Fill collection property from a property grid

V

Vlado

VS2005 C#

I have something like this:

public class MyControl : Panel
{
private SomeCollection myCollectionProp = new SomeCollection();
public SomeCollection MyCollectionProp
{
get
{
return this.myCollectionProp;
}
}
}

I put MyControl on a form (from toolbox). When I want to fill a
MyCollectionProp in a property grid I get message
"Object reference not set to an instance of an object." I can not figure
why.
Then, I tried to debug MyControl's design-time (Debug -> Attach to
Process... -> devenv) but when I try to open a collection editor from a
property grid, no exception is thrown and I can fill MyCollectionProp
normally. If I stop debugging and save changes and then start debug of
application everything works fine.

Can anyone explain what am I doing wrong and what is the difference between
normal design-time and design-time debug?

If that is some kind of bug maybe there is a workaround or should I create
my forms in design-time debug?

I hope you understand the problem. Any clue would be appreciated.

Vlado
 
S

Stoitcho Goutsev \(100\)

When this exception is thrown when you click on the ellipsis button for the
collection or when you click on the button to create new item for the
collection (inside the collection edtor)?

In other words - do you see the collection editor at all?
 
V

Vlado

Stoitcho Goutsev (100) said:
When this exception is thrown when you click on the ellipsis button for
the collection or when you click on the button to create new item for the
collection (inside the collection edtor)?

In other words - do you see the collection editor at all?

No, I do not see the collection editor.

Funny thing is that this happens to me in editor inherited from UITypeEditor
also.
I made a dropdown style editor for one of my properties and it worked fine
in VS2003 but in VS2005 sometime I get exception "Object reference not
set..." when I click on the dropdown button in property grid. I have tried
with debugging the design time and I discovered that in
EditValue(ITypeDescriptorContext context, IServiceProvider provider, object
value)
method, parameter "context" is null.
I suspect that the same thing happens with the collection editor.

Any conclusions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top