Tuesday, May 22, 2007

Radio Buttons selection Problem

Tips Only for VC++ Developers
-----------------------------------------------

read this article with patience u may wonder the things about it...

I explained each and every steps ... So Dont mistake me....( u r all genius but I am so stupid to
rememeber the things...)

Follow the steps :
-----------------------
1.Open the Visual Studio 6.0
2.Select the "MFC AppWizard Exe" option
3. Give the project name
4.Select the "Dialog based application" and click the "Finish" button.
5.Next Click on "Resources" Tab in the Source code Browse window
6.Within Resources, click on Dialog and select the program's dialog

Do the following steps in Sequence :

7. Place the "Group Box" in the dialog we can call it as GroupBox1

8.Place two option buttons(Radio1,Radio2) within this GroupBox1

9. Place another "Group Box" in the dialog we can call it as GroupBox2

10.Place two option buttons(Radio3,Radio4) within this GroupBox2

11. run the application

12.Select the radio1 button in GroupBox1.

13.Next Select radio3 button in GroupBox2.Now the radio3 button is selected but the previous selection

radio1 button is deselected...

Am I right ?

Actually in a programming scenario,

the selection of radio button in one GroupBox must not affect the selection of radio button in another groupBox.

Here it is not like that...

So we have to do some thing different...



How can we make the selection of radio button in one GroupBox must not affect the selection of radio button in another groupBox ?

Solution :

Right click the Radio1 button's properties and select the "Group" check box .
Right click the radio3 button's properties and select the "Group" check box.

At conclusion :

make sure all the controls are placed in consecutive tab order.

(select the menu Layout-->Tab Order (Ctrl+D) )

For the 1st radio button, make sure the "Group" flag is set true (WS_GROUP, but you can do it in the resource editor.)
(select the "Group" check box of the first radio button).
Make sure the rest of the radio buttons have the "Group" flag set false.(unchecked status of "Group" check box of the first radio button).
The "Group" flag tells Windows that this control is the 1st control in a group.




( we may check it by opening the .rc file in a notepad )


Note :- But if u are selecting the "Group" check box of all the radio properties .
See the result.



PostScript :
I faced this problem during developement and finally got a solution for this problem... thanks for ur patience.Sorry for my bad tanglish..

No comments: