Click here to Skip to main content
15,887,430 members
Home / Discussions / C#
   

C#

 
GeneralRe: String to Object Instance Problem Pin
Pete O'Hanlon17-Jul-12 4:19
mvePete O'Hanlon17-Jul-12 4:19 
GeneralRe: String to Object Instance Problem Pin
atoi_powered17-Jul-12 4:21
atoi_powered17-Jul-12 4:21 
GeneralRe: String to Object Instance Problem Pin
Pete O'Hanlon17-Jul-12 4:25
mvePete O'Hanlon17-Jul-12 4:25 
GeneralRe: String to Object Instance Problem Pin
BobJanova17-Jul-12 3:58
BobJanova17-Jul-12 3:58 
GeneralRe: String to Object Instance Problem Pin
Pete O'Hanlon17-Jul-12 4:17
mvePete O'Hanlon17-Jul-12 4:17 
AnswerRe: String to Object Instance Problem Pin
BobJanova17-Jul-12 3:58
BobJanova17-Jul-12 3:58 
GeneralRe: String to Object Instance Problem Pin
atoi_powered17-Jul-12 4:09
atoi_powered17-Jul-12 4:09 
GeneralRe: String to Object Instance Problem Pin
BobJanova18-Jul-12 2:33
BobJanova18-Jul-12 2:33 
Define 'didn't work'.

Are all your picture boxes children of the same control? If so, you should use 'parentOfPBs.Controls' not 'this.Controls'. If not, you will have to traverse the whole control tree; I suggest you do this once and stash them in a list as it can be quite slow on a big form. You can use a standard recursive tree traversal similar to

public static List<T> GetControlsInTree<T>(Control parent) where T: Control {
 List<T> result = new List<T>
 AddControlsInTree(parent, result);
 return result;
}

static void AddControlsInTree<T>(Control parent, List<T> list) where T: Control {
 foreach (Control c in parent.Controls){
  T t = c as T;
  if (t != null) list.Add(t);
  AddControlsInTree(c, list);
 }
}


You can stash the list of picture boxes after form initialisation (after you call InitializeComponent in the constructor, for example):
List<PictureBox> pictures = GetControlsInTree<PictureBox>(this);


Then you can iterate over them at will:
private void ResetPictureBoxes()
 foreach(PictureBox picture in pictures)
  picture.BackgroundImage = Resource1.island;
}

GeneralRe: String to Object Instance Problem Pin
atoi_powered18-Jul-12 3:11
atoi_powered18-Jul-12 3:11 
QuestionBetter date / time parse? Pin
SledgeHammer0116-Jul-12 12:50
SledgeHammer0116-Jul-12 12:50 
AnswerRe: Better date / time parse? Pin
Peter_in_278016-Jul-12 14:01
professionalPeter_in_278016-Jul-12 14:01 
AnswerRe: Better date / time parse? Pin
BobJanova17-Jul-12 0:14
BobJanova17-Jul-12 0:14 
QuestionRepresenting a 4 digit integer in 2 positions alphanumeric placeholder. Pin
RK KL16-Jul-12 8:23
RK KL16-Jul-12 8:23 
GeneralRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
OriginalGriff16-Jul-12 8:38
mveOriginalGriff16-Jul-12 8:38 
GeneralRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
RK KL16-Jul-12 8:46
RK KL16-Jul-12 8:46 
GeneralRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
PIEBALDconsult16-Jul-12 9:27
mvePIEBALDconsult16-Jul-12 9:27 
GeneralRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
Ian Shlasko16-Jul-12 9:41
Ian Shlasko16-Jul-12 9:41 
GeneralRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
harold aptroot16-Jul-12 8:52
harold aptroot16-Jul-12 8:52 
GeneralRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
OriginalGriff16-Jul-12 9:40
mveOriginalGriff16-Jul-12 9:40 
AnswerRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
Big Daddy Farang16-Jul-12 8:40
Big Daddy Farang16-Jul-12 8:40 
AnswerRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
RK KL16-Jul-12 9:08
RK KL16-Jul-12 9:08 
AnswerRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
PIEBALDconsult16-Jul-12 9:41
mvePIEBALDconsult16-Jul-12 9:41 
GeneralRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
Paul Conrad16-Jul-12 10:52
professionalPaul Conrad16-Jul-12 10:52 
GeneralRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
RK KL17-Jul-12 3:57
RK KL17-Jul-12 3:57 
GeneralRe: Representing a 4 digit integer in 2 positions alphanumeric placeholder. Pin
PIEBALDconsult17-Jul-12 6:57
mvePIEBALDconsult17-Jul-12 6:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.