Group2D’s have some quirky features. It is not easy to write some generic meaningful change BorderColor method. This problem has nothing to do with Extension Methods.
You can find out how many Object2D’s exist in the Group2D collection with the Count property. But you cannot iterate through them one at a time to change a property like BorderColor. From the Group2D itself, you have no access to the Object2D’s inside. You can remove one at a specified position (RemoveObjectAt). But you cannot, as best I can tell, find out anything about the Object2D at any given position much less change an attribute of one.
To deal with the issue, you might maintain a parallel array of Object2Ds (perhaps in the same class) and insist that all the elements in the Group2D were placed there as members of the array. The Group2D has some kind of “connection” back to the Object2Ds that were put in it. You can change the attributes of one of the Object2Ds in the array. If you do that, you don’t have to do anything else. Because of the “connection” the Object2D in the Group2D (which you might consider to be a pointer back to the member of the array) is appropriately changed and displays as changed.
One thing that is interesting is that it is perfectly possible to add to the Group2D an Object2D that is a variable in some method that does the addition. (AddObject). When that method completes, that variable, declared locally, goes out of scope, and you have no way of referring to it in the future. So its “connected” object in the Group2D has no way of having its attributes changed. There are forever frozen.
It is sort of interesting that the locally assigned variable, itself dead and gone, lives on, as it were, in the Group2D.
When I was dreaming about being able to iterate through a Group2D and change the BorderColor attribute of each member, I thought that it was a feature that if one of those members was, in fact, a Group2D itself, it would cause no problem. Since Group2D’s have a BorderColor attribute, however meaningless, you could assign a color to it and nothing would happen and no error would be generated.
Indeed, if you iterate thought the “parallel” array that you perhaps have created, you can do the simple BorderColor assignment without worrying about whether that particular element was, in fact, itself a Group2D. If it actually is one, no error is generated and nothing “happens”. So in this context, you can consider the fact that a Group2D can be assigned a BorderColor is a convenient feature.
Reader beware: I do not have much experience with all of this. I am relating only what I believe I have seen. I cannot find most of this in the Documentation so I am just sharing what are my impressions.