c# - Group 64 picture boxes into picturebox array -
i created 64 picture boxes using gui. group these picture boxes picturebox array because need update pictures in said picture boxes.
i have following code:
private picturebox[] pictureboxarray= new picturebox[64]; //initialize array group picture boxes picture box array private void main_load(object sender, eventargs e) { convertguipbtoguipbarray(ref pictureboxarray); } public static void convertguipbtoguipbarray(ref picturebox[] pictureboxarray) { foreach(picturebox index in pictureboxarray) { //some code following: pictureboxarray[0]=picturebox1; //this name of picturebox on gui pictureboxarray[1]=picturebox2; pictureboxarray[2]=picturebox3; . . . pictureboxarray[63]=picturebox64; // } i have seen commands of controls.oftype don't seem understand it. suggestions appreciated. in advance!
assuming you're stuck design of form , 64 individual pictureboxnn properties, basic reflection can populate array needed. don't think controls can guaranteed have right ordering.
for (int = 0; < 64; i++) { pictureboxarray[i] = (picturebox)gettype().getproperty("picturebox" + (i + 1)).getvalue(this); }
Comments
Post a Comment