Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C# Programming

iterating through radio button collection as an array


I know you can iterate through a collection of radio buttons in a
panel, using  a "for each in control" type iteration that c# supports,
but is it possible to iterate through the radio buttons collection, as
if they were an array of radio buttons ?

Basically i want to plonk the radio buttons on a panel then use a for
loop to index through the radio buttons with an idenex to check thier
state.

I want to do it this way becasue i want to make use of the index
integer when i find the checked radio button in the control group

thanks

Peted

<Peted> wrote in message news:5nfbt25b96nemvc9kl90fhnr6ba4ub1ukf@4ax.com...
>I know you can iterate through a collection of radio buttons in a
> panel, using  a "for each in control" type iteration that c# supports,
> but is it possible to iterate through the radio buttons collection, as
> if they were an array of radio buttons ?

You will have to cast them to RadioButton

foreach(Control c in myRadioButtonsContainer.Controls)
{

    // whatever style you prefer for the casting / check

    if(c is RadioButton)
    {
        RadioButton rb = (RadioButton)c;
    }

    RadioButton rb = c as RadioButton;
    if(rb != null)
    {

    }

}

PS

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc