Use of the single-choice button control (ridio button)

Source: Internet
Author: User

 

 

VC study Note 5: Use of the single-choice button control (ridio button)

1. Group Single-choice buttons:
Set attributes for the first single-choice button in each group: group, tabstop, and auto. Set attributes for other buttons: tabstop and auto.

For example:
Ridio1, ridio2, and ridio3 are a group, and ridio4 and ridio5 are a group.

Set ridio1 attributes: group, tabstop, auto
Set the ridio2 attribute: tabstop, auto
Set the ridio3 attribute: tabstop, auto

Set ridio4 attributes: group, tabstop, auto
Set the ridio5 attribute: tabstop, auto

Ii. Use classwizard to define a single-choice controlValue variable, Each group can only define one. For example, m_iridio1 and m_iridio4.

 

3. assign values to m_iridio1, 0 1st; 1 second; 2 third; value appended updatedata (false)

M_iridio1 = 2;

Updatedata (false );

Select the third button.

4. Use classwizard to generate the click message function of each radio button and add the following content:

Void cweditview: onradio1 ()
{
M_iridio1 = 0; // The first radio button is selected.
}

Void cweditview: onradio2 ()
{
M_iridio1 = 1; // The second radio button is selected.
}

Void cweditview: onradio3 ()
{
M_iridio1 = 2; // The third radio button is selected.
}

Void cweditview: onradio4 ()
{
M_iridio4 = 0; // The fourth radio button is selected.
}

Void cweditview: onradio5 ()
{
M_iridio4 = 1; // The fifth radio button is selected.
}

 

======================================

In step 3, set the default button in oninitdialog to be more flexible.
4. Set the default button:
When defining a control variable, classwizard sets the initial value of the variable to-1 in the constructor. You only need to change it to another value.
For example:
// {Afx_data_init (cweditview)
M_ridio1 = 0; // The first radio button is selected at the beginning.
M_ridio4 = 0; // The fourth radio button is selected in the initial stage.
//} Afx_data_init

 

 

References

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.