i have 100 files in resources named "1.png", "2.png". have picturebox[]
array generated code, , want set array[i].image = string.format("properties.resources.{0}.png", i);
not work.
what best way this?
you need use reflection, following task:
var properties = typeof(properties.resources).getproperties (bindingflags.static | bindingflags.public | bindingflags.nonpublic); picturebox[] array = new picturebox[100]; int counter = 0; foreach (propertyinfo property in properties) { var image = property.getvalue(null, null) system.drawing.bitmap; if (image != null && counter < array.length) { array[counter] = new picturebox(); array[counter++].image = image; } }
remember include using system.reflection;
@ top.
Comments
Post a Comment