wxRadioBox without default selection

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

wxRadioBox without default selection

Post by deepti »

Hi All,

Is it possible to implement a wxRadioBox without any default selection?
I am basically looking to implement a control such that the user is always forced to choose a selection and is not allowed to proceed otherwise.
wxRadioBox and wxCheckedlistbox are 2 such controls i could think of. Is there anything else which can help me achieve this behavior?

Please help!
Kvaz1r
Super wx Problem Solver
Super wx Problem Solver
Posts: 357
Joined: Tue Jun 07, 2016 1:07 pm

Re: wxRadioBox without default selection

Post by Kvaz1r »

Hi.
Not sure, but maybe group of wxRadioButton is that what you are looking for.

From the documentation:
wxRB_GROUP:
Marks the beginning of a new group of radio buttons.
rando
Knows some wx things
Knows some wx things
Posts: 35
Joined: Fri Nov 09, 2018 9:11 pm

Re: wxRadioBox without default selection

Post by rando »

From the wxRadioBox docs
virtual void wxRadioBox::SetSelection ( int n )

Sets the selection to the given item.

Notice that a radio box always has selection, so n must be valid here and passing wxNOT_FOUND is not allowed.
So to answer your question specifically for the wxRadioBox: You must have a selection.

Expanding on Kvza1r's idea, you can mimic the look of the radio box by putting wxRadioButtons inside a wxStaticBoxSizer
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Re: wxRadioBox without default selection

Post by deepti »

Thank you so much for the replies
Post Reply