Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Help with Collections

Help with Collections

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheBlindWatchmaker
    wrote on last edited by
    #1

    Greetings! I have a set of 6 RadioButtons, one of which is set based on a user-selection in a ListBox on the same form. What I want to do is to disable the other 5 RadioButtons after the user makes the selection and one RadioButton is set. I'm assuming that a collection is the best way to do this, so I can write some code that disables every RadioButton that is not the one that is selected. Could you help me define this Collection? I've looked through MSDN and pages online but I'm a little confused about how one defines a collection. Thanks!

    E 1 Reply Last reply
    0
    • T TheBlindWatchmaker

      Greetings! I have a set of 6 RadioButtons, one of which is set based on a user-selection in a ListBox on the same form. What I want to do is to disable the other 5 RadioButtons after the user makes the selection and one RadioButton is set. I'm assuming that a collection is the best way to do this, so I can write some code that disables every RadioButton that is not the one that is selected. Could you help me define this Collection? I've looked through MSDN and pages online but I'm a little confused about how one defines a collection. Thanks!

      E Offline
      E Offline
      eggsovereasy
      wrote on last edited by
      #2

      In page_load or where you initialize your variables do:

      List<RadioButton> buttons = new List<RadioButton>();

      buttons.Add(RadioButton1);
      buttons.Add(RadioButton2);
      buttons.Add(RadioButton3);
      buttons.Add(RadioButton4);
      buttons.Add(RadioButton5);
      buttons.Add(RadioButton6);

      Then you can iterate throug them with loops:

      foreach (RadioButton rb in buttons)
      {
      if(!rb.Checked)
      rb.Enabled = false;
      }

      T 1 Reply Last reply
      0
      • E eggsovereasy

        In page_load or where you initialize your variables do:

        List<RadioButton> buttons = new List<RadioButton>();

        buttons.Add(RadioButton1);
        buttons.Add(RadioButton2);
        buttons.Add(RadioButton3);
        buttons.Add(RadioButton4);
        buttons.Add(RadioButton5);
        buttons.Add(RadioButton6);

        Then you can iterate throug them with loops:

        foreach (RadioButton rb in buttons)
        {
        if(!rb.Checked)
        rb.Enabled = false;
        }

        T Offline
        T Offline
        TheBlindWatchmaker
        wrote on last edited by
        #3

        ...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups