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
Experienced Solver
Experienced Solver
Posts: 88
Joined: Tue Jul 17, 2018 5:38 pm

wxRadioBox without default selection

Post by deepti » Tue Jan 29, 2019 6:17 pm

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
Knows some wx things
Knows some wx things
Posts: 48
Joined: Tue Jun 07, 2016 1:07 pm

Re: wxRadioBox without default selection

Post by Kvaz1r » Tue Jan 29, 2019 7:56 pm

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: 25
Joined: Fri Nov 09, 2018 9:11 pm

Re: wxRadioBox without default selection

Post by rando » Wed Jan 30, 2019 3:30 pm

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
Experienced Solver
Experienced Solver
Posts: 88
Joined: Tue Jul 17, 2018 5:38 pm

Re: wxRadioBox without default selection

Post by deepti » Wed Jan 30, 2019 4:14 pm

Thank you so much for the replies

Post Reply