array's containing radiobuttons

  • Thread starter Thread starter John Devlon
  • Start date Start date
J

John Devlon

Hi everyone ...

does anyone know if it's possible to create an array, filled with
radionbuttons ....

.... radiobuttons that allready exists on the form ....

for example ...

Dim array() as radiobutton
array(0) = radiobutton1

array(1) = radiobutton2
array(2) = radiobutton3


Could this work ? (syntax is probebly wrong)

Thanx

John
 
Hi everyone ...

does anyone know if it's possible to create an array, filled with
radionbuttons ....

... radiobuttons that allready exists on the form ....

for example ...

Dim array() as radiobutton
array(0) = radiobutton1

array(1) = radiobutton2
array(2) = radiobutton3


Could this work ? (syntax is probebly wrong)

Thanx

John

It could work, but you need to dim the array to the correct size first
:) I might use an arraylist for this, but it requires a cast to access
the elements... Or, you could put them in a hashtable indexed by the
name...
 
Hi tom,

what do you mean by "cast" ?

Thanx

John

Well arraylist holds objects... So, to use the radiobuttons you have to
do something like this:

DirectCast (radioButtons[2], RadioButton).Text = "The Text"
 
You can just dim an array:

Dim RadioButtons() As RadioButton = {RadioButton1, RadioButton2}

This will create an array of two radio buttons.

If you need to add more later, you will have to ReDim Preserve the
array and make it the correct size.
 
You can just dim an array:

Dim RadioButtons() As RadioButton = {RadioButton1, RadioButton2}

This will create an array of two radio buttons.

If you need to add more later, you will have to ReDim Preserve the
array and make it the correct size.

Yes, you can do that... I said that in my original post. Sometimes,
though, if you are dynamically adding controls at runtime, using an
arraylist or hashtable can be more convienient.
 
Tom said:
Chris said:
Sometimes, though, if you are dynamically adding controls at runtime, using an
arraylist or hashtable can be more convienient.

Agreed. And when we finally get generics in VS2005, it will be even
more convenient because we won't have to cast anymore.
 
Back
Top