Page 1 of 1

Need Examples on Referencing Checkbox Values in C++

Posted: Fri Apr 01, 2016 7:31 pm
by ColleenKobe
Hi! I hope this question is easy.

Is there a tutorial somewhere showing how to modify the values of a checkbox inside the C++ code?

I created a set of checkboxes called "CheckBoxes_ListBox" with the following values:

New Year's Day;Memorial Day;Independence Day;Labor Day;Thanksgiving;Christmas Eve;Christmas Day;New Year's Eve

In the same sizer, I added two buttons: one says "Check All," and the other says "Uncheck All." The goal, of course, is to be able to check or uncheck all the boxes with a single click.

I created the events for clicking the buttons and built the event handler code. So it's there. And now I don't know how to reference the checkbox values.

So, again, is there code I can study online for examples?

I could also use examples for radio buttons and drop-down lists.

----
Per http://forums.codelite.org/viewtopic.php?f=11&t=804:
1. Your codelite version: 9.1.5
2. Is it a self compiled version of codelite: I don't understand this question. I did not compile it; I'm using it as-is. Does that answer the question?
3. Your OS: Windows 7. Target is Windows.
4. Compiler version: g++ TDM-GCC, version 5.1.0.3

Thank you!

Colleen

Re: Need Examples on Referencing Checkbox Values in C++

Posted: Fri Apr 01, 2016 8:02 pm
by eranif
In the event handler for the event 'wxEVT_BUTTON_CLICKED' of the "Check All" button you can do this:

Code: Select all

void MyClass::OnCheckAll(wxCommadEvent& e)
{
    for(size_t i=0; i<CheckBoxes_ListBox->GetCount(); i++){
        CheckBoxes_ListBox->Check((unsigned int)i, true);
    }
}

void MyClass::OnUnCheckAll(wxCommadEvent& e)
{
    for(size_t i=0; i<CheckBoxes_ListBox->GetCount(); i++){
        CheckBoxes_ListBox->Check((unsigned int)i, false);
    }
}

Eran

Re: Need Examples on Referencing Checkbox Values in C++

Posted: Fri Apr 01, 2016 8:10 pm
by ColleenKobe
YAAAY! That worked!

Thank you, Eran! You're brilliant!

Colleen