简体   繁体   中英

Initialize radio button as checked

I am having trouble initializing a radio button as checked. What I mean is when I open the form, none of my 2 radio buttons are checked, but they work fine after I check on of them. I tried setting one of them as checked in the Form constructor, but it still appears as unchecked:

public frmPreferences(Capitals capit)
{
    InitializeComponent();
    radEnglish.Enabled = true;
}
radEnglish.Enabled = true

This does not set the CheckBox to a Checked state, it enables the control. You could do this in the designer, or you could use the line

radEnglish.Checked = true;

For WPF it's

radEnglish.IsChecked = true;

The enabled property doesn't check the control, it (not surprisingly) enables it. Use this instead:

radEnglish.Checked = true;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM