RadioButton ReadOnly

I can set my textboxes to ReadOnly is it possible to set a property in a radiobutton list to be read only
Mr_ShawAsked:
Who is Participating?
 
käµfm³d 👽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

0
 
brawneyCommented:
Look at the "Enabled" property.  You can also set the Enabled property on a Panel that the radio buttons are contained in.
0
 
Mr_ShawAuthor 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..

0
 
Éric MoreauSenior .Net ConsultantCommented:
0
 
Mr_ShawAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.