Results 1 to 3 of 3

Thread: [RESOLVED] Controls on a Windows Form

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    48

    Resolved [RESOLVED] Controls on a Windows Form

    I have a form with quite a few controls on : labels, text boxes, masked text boxes, check boxes etc.

    I want to be able to write something that checks the values of certain check boxes, if this are checked then go off and do something else.

    I initially started by checking each one in turn, but I don't think that this is the best way forward.

    I almost want something like:

    foreach CheckBox check in this.Controls - but need to limit to check boxes only.

    Can anyone help?

    Many thanks

    Mark

  2. #2
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Re: Controls on a Windows Form

    CheckBox[] checkBoxes = new CheckBox[] {checkBox1, checkBox2, checkBox5};
    foreach (CheckBox c in checkBoxes) { . . . }

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    48

    Re: Controls on a Windows Form

    Quote Originally Posted by nebulom
    CheckBox[] checkBoxes = new CheckBox[] {checkBox1, checkBox2, checkBox5};
    foreach (CheckBox c in checkBoxes) { . . . }
    I didn't think of using an array. Will limit the number of passes too..

    Cool, thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width