Resources | Resources |



Grouping radio buttons

Radio buttons are sets of buttons such that only one button in a given group may be selected at any one time. To allow applications decide how to group radio buttons in their user interface, radio buttons are not associated with any group at creation time, the group must be specified at a later time.

This topic describes the process for associating a set of radio buttons with each other so that only one element in the group is selected at a time.

To group a set of radio buttons, an application needs to do the following:

  1. Create a basic model to serve as the group controller for the radio buttons.
  2. Attach the model to the radio buttons.

For more information on grouping radio buttons, see Creating and grouping radio buttons.

Example: create a group model

A group model is any model that implements AEEIID_IModel. It will generally be the default AEECLSID_CModel, as its only purpose is to coordinate the state of the radio buttons. An application can create a group model as follows:

ERR_TRY( ISHELL_CreateInstance(me->pIShell, AEECLSID_CModel, (void**)&piGroupModel) );    

Example: set the model on each radio button

Set the group model to be the view model for each radio button in the radio button group by calling IWidget_SetViewModel(), as follows:

ERR_TRY( IWidget_SetViewModel(piwButton, piGroupModel) );