How to add Forbidden Zones dynamically?

4 posts, 0 answers
  1. Alec
    Alec avatar
    43 posts
    Member since:
    Mar 2009

    Posted 16 Jul 2009 Link to this post

    I tried:

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

  2. Jim
    Jim avatar
    31 posts
    Member since:
    Jun 2009

    Posted 16 Jul 2009 Link to this post

    Try this line:

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

  3. Alec
    Alec avatar
    43 posts
    Member since:
    Mar 2009

    Posted 16 Jul 2009 Link to this post

    but what if i need to append to the array using a for loop?

    i.e.

    for{
        

    dock.ForbiddenZones[intLength] = strZoneId;


    }
  4. Jim
    Jim avatar
    31 posts
    Member since:
    Jun 2009

    Posted 20 Jul 2009 Link to this post

    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]; 

Back to Top