المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Dynamically referencing a control - how do I do this (better)?



C# Programming
01-15-2010, 07:00 PM
I have a groupBox that has N PictureBox controls on it.
Each PictureBox is named thmb1-N e.g thmb26.

I have a list of paths, of thumbnail images, which I want to iterate through and set PictureBox control Image******** properties for each PictureBox .

The code I have written below is a first rather messy and quick attempt - which is cumbersome and I really don't want to be iterating through every object.

Is there a better way of doing this?

If I could do something like thmb + N.Image******** = ... but i realise I cannot do this in C# so any help in directing me towards how to do this would be much appreciated.

Guy


for (int i = 0; i <span class="code-keyword">