PropertyDescriptorCollection.Remove()

  • Thread starter Thread starter FrankYM
  • Start date Start date
F

FrankYM

Hi all,

I have a general question concerning the capability of the
PropertyDescriptorCollection. It seems to be impossible to remove a
PropertyDescriptor savely using Remove or RemoveAt. I use framework
1.1. Why does the following code always crash resulting in the error
message "Source array was not long enough. Check srcIndex and length,
and the array's lower bounds.":

PropertyDescriptorCollection PDC = new
PropertyDescriptorCollection(null);
PDC.Add(new MyItemDescriptor(null, "first", ""));
PDC.Add(new MyItemDescriptor(null, "second", ""));
PDC.RemoveAt(0);

But removing the second element works this time:

PropertyDescriptorCollection PDC = new
PropertyDescriptorCollection(null);
PDC.Add(new MyItemDescriptor(null, "first", ""));
PDC.Add(new MyItemDescriptor(null, "second", ""));
PDC.RemoveAt(1);

For me it's impossible to foresee when it will fail, sometimes it's
removable sometimes not.

Thanks in advance,

Frank
 
Im having the same problem. I stepped through my code, and the Length of
the PropertyDescriptorCollection implementation was 2, when I got this
error.

It was trying to remove element at position 0.

Brian Takita
 

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

Back
Top