We help IT Professionals succeed at work.

RadioButton ReadOnly

Mr_Shaw
Mr_Shaw asked
on
Medium Priority
926 Views
Last Modified: 2013-12-17
I can set my textboxes to ReadOnly is it possible to set a property in a radiobutton list to be read only
Comment
Watch Question

Commented:
Look at the "Enabled" property.  You can also set the Enabled property on a Panel that the radio buttons are contained in.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
I have used enabled, but it greys out the buttons... this is not good for the those who can't see so well.

With my textboxes I changed them from enabeled= false to readonly = true and I retained the correct font color..

Éric MoreauSenior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016
Commented:
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015
Commented:
I have attached some code which should simulate what you are trying to achieve--it is not merely a property, but should be adequate:

You would need to change how you set the R/O flag--here I'm just using a button to set/unset the flag. I made 3 radio buttons on my form and set all of their CheckChanged handlers to the function radioButton3_CheckChanged. This is the reason I casted the buttons within that function.
private bool READONLY;
private RadioButton RADIOBUTTON;
 
public Form1()
{
    this.READONLY = false;
    InitializeComponent();
}
 
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
    if (((RadioButton)sender).Checked)
    {
        this.RADIOBUTTON = (RadioButton)sender;
    }
 
    if (this.READONLY)
    {
        this.RADIOBUTTON.Checked = true;
    }
}
 
private void button1_Click(object sender, EventArgs e)
{
    this.READONLY = !this.READONLY;
    this.label1.Text = this.READONLY.ToString();
}

Open in new window

Author

Commented:
thanks
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.