?
Solved

RadioButton ReadOnly

Posted on 2009-02-16
5
Medium Priority
?
840 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
0
Comment
Question by:Mr_Shaw
5 Comments
 
LVL 4

Assisted Solution

by:brawney
brawney earned 400 total points
ID: 23651645
Look at the "Enabled" property.  You can also set the Enabled property on a Panel that the radio buttons are contained in.
0
 

Author Comment

by:Mr_Shaw
ID: 23651683
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
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 400 total points
ID: 23652141
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1200 total points
ID: 23652156
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
 

Author Closing Comment

by:Mr_Shaw
ID: 31547399
thanks
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Integration Management Part 2
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question