473,508 Members | 2,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PropertyDescriptorCollection.Remove()

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
Jul 21 '05 #1
1 2202
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

FrankYM wrote:
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

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
55527
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
11
3056
by: Tony Johansson | last post by:
Hello! I have some problem with STL function remove I have two classes called Handle which is a template class and Integer which is not a template class. The Integer class is just a wrapper...
6
4933
by: Arne Claus | last post by:
Hi If've just read, that remove() on a list does not actually remove the elements, but places them at the end of the list (according to TC++STL by Josuttis). It also says, that remove returns a...
3
3793
by: Don | last post by:
My user control has a combobox with an arraylist attached to it along with custom add and remove methods. The "Add" method is working great. However I don't understand why the "Remove" method...
1
411
by: FrankYM | last post by:
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...
3
5380
by: Niyazi | last post by:
Hi all, I have a dataTable that contains nearly 38400 rows. In the dataTable consist of 3 column. column 1 Name: MUHNO column 2 Name: HESNO Column 3 Name: BALANCE Let me give you some...
6
7160
by: tshad | last post by:
Is there a reason to use session.remove over session.contents.remove? Don't they both remove the key and data from the contents collection? I assume that session(x) = nothing does essentially...
7
6587
by: Susan Mackay | last post by:
I have a data table that is connected to a database table with a data adapter in the 'standard' manner. However I want to be able to remove selected rows from the data table (i.e. no longer...
6
5968
by: sam_cit | last post by:
Hi Everyone, I'm using remove() function to delete a file, and i observed the following behavior, Concerned file : sample.txt Operation : i open the file in read mode and don't close the...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.