This is a migrated thread and some comments may be shown as answers.

How to add Forbidden Zones dynamically?

3 Answers 45 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Alec
Top achievements
Rank 1
Alec asked on 16 Jul 2009, 07:01 AM
I tried:

dock.ForbiddenZones[0] = "Zone Name";
But it keeps saying Index was outside the bounds of the array.

3 Answers, 1 is accepted

Sort by
0
Jim
Top achievements
Rank 1
answered on 16 Jul 2009, 09:07 AM
Try this line:

RadDock1.ForbiddenZones = new string[] { "RadDockZone2" }; //RadDockZone2 is the ID of the zone

0
Alec
Top achievements
Rank 1
answered on 16 Jul 2009, 11:58 PM
but what if i need to append to the array using a for loop?

i.e.

for{
    

dock.ForbiddenZones[intLength] = strZoneId;


}
0
Jim
Top achievements
Rank 1
answered on 20 Jul 2009, 07:57 AM
The dock.ForbiddenZones is of type string [] array and by default is not instantiated (so an element at a given index cannot be accessed because such an index does not exist in the first place). You have to instantiate it yourself. This can be done by the following code line:

dock.ForbiddenZones = new string[10]; 

Tags
Dock
Asked by
Alec
Top achievements
Rank 1
Answers by
Jim
Top achievements
Rank 1
Alec
Top achievements
Rank 1
Share this question
or