How to access properties on dynamically created radio button

S

Steve Clark

Hope someone can provide some help here. In an application we are
developing with VB.NET, we generate several radio buttons on the main form
dynamically. We want to programatically mark a specific radio button as
"checked" or "unchecked". The buttons reside on a panel, and accessing them
via frmMain.pnlButtons.Control.Item(X).... does not give us access to the
"Checked" property. Seems like we ought to be able to do this...any
suggestions?

Thanks.

Steve
 
H

Herfried K. Wagner [MVP]

* "Steve Clark said:
Hope someone can provide some help here. In an application we are
developing with VB.NET, we generate several radio buttons on the main form
dynamically. We want to programatically mark a specific radio button as
"checked" or "unchecked". The buttons reside on a panel, and accessing them
via frmMain.pnlButtons.Control.Item(X).... does not give us access to the
"Checked" property. Seems like we ought to be able to do this...any
suggestions?

\\\
DirectCast(frmMain.pnlButtons.Controls(X), CheckBox).Checked = True
///
 
C

Cor

Hi Steve,

It depends how you create them, if it is not using an array it should be as
simple as

\\\
me.myradiobutton.checked = true
///
Cor
 
C

Cor

* "Steve Clark said:
\\\
DirectCast(frmMain.pnlButtons.Controls(X), CheckBox).Checked = True
///

Are you sure of that, does a cast of a CheckBox also fit for a RadioButton?

:)) (I know it: typos)

(Hi steve if you read it and you are able to access them using that X,
change CheckBox for RadioButton)

Cor
 
H

Herfried K. Wagner [MVP]

* "Cor said:
Are you sure of that, does a cast of a CheckBox also fit for a RadioButton?

:)) (I know it: typos)

I wondered too when replying.
 
S

Steve Clark

Herfried K. Wagner said:
\\\
DirectCast(frmMain.pnlButtons.Controls(X), CheckBox).Checked = True
///

Thanks, Herfried. That works great...just what I was looking for. Don't
really understand why we need to do that, but I can live with it. Thanks
again. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top