locked
Array of arrays assigns value to entire row RRS feed

  • Question

  • I have an array of arrays defined as:

    Private squaredata(8)() as MyCustomType

    I initialize all the values in the Loaded event so that it is an 8x8 array of arrays. However, whenever I assign a value to a property, such as:

    squaredata(x)(y).IsSelected=True

    It ends up assigning the value to every element in the row, as if I had entered the following instead:

    squaredata(0)(y).IsSelected=True
    squaredata(1)(y).IsSelected=True
    squaredata(2)(y).IsSelected=True
    squaredata(3)(y).IsSelected=True
    squaredata(4)(y).IsSelected=True
    squaredata(5)(y).IsSelected=True
    squaredata(6)(y).IsSelected=True
    squaredata(7)(y).IsSelected=True
    squaredata(8)(y).IsSelected=True

    Why is it assigning the value to every element in the entire row? Any help would be appreciated. Thanks.


    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Thursday, November 21, 2013 8:32 PM

Answers

  • I think I found my problem. When initializing the array, I was reusing a temporary value, and I think the fact that it was a reference type and I wasn't "New"ing it was causing the values to get assigned to the entire row. I don't know if my modification is the best, but I have it working now.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Friday, November 22, 2013 3:52 AM