wxGrid - retrieve all cell combo box values Topic is solved

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
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

wxGrid - retrieve all cell combo box values

Post by Widgets »

I know I can retrieve the currently selected value of such a combo box, but I cannot find an example of the full list being recovered.
Is it possible to retrieve, at some later time and in a different function/event handler, all the values assigned to a combo box cell with a statement such as

Code: Select all

m_gridTemplates->SetCellEditor(         szRows - 1, 3, new wxGridCellChoiceEditor( wasListChoices ));
where wasListChoices contains the values or do I need to somehow remember these values in some class member, such as in an array of strings, or reconstruct them the same way I did to fill the combo box?
This is needed to allow the user to modify the contents of the list.
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxGrid - retrieve all cell combo box values

Post by ONEEYEMAN »

Hi,
How do you build such a combo box?
Did you retrieve the values from DB? Hardcode them? Anything else?

Thank you.
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: wxGrid - retrieve all cell combo box values

Post by Widgets »

The current values are saved in a preferences file, but I want the user to be able to add to or modify values as he sees fit to meet his needs.
The values will be used to identify/label some data to be saved in DB
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxGrid - retrieve all cell combo box values

Post by ONEEYEMAN »

Hi,
OK, so you read this file and those values will be stored inside the array, right? And this array can be stored as a member of the frame that holds the grid.
Or you could just retrieve the combo box and add/remove the values as you can see fit.

It is up to you - what is easier for you to code.

Thank you.
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: wxGrid - retrieve all cell combo box values

Post by Widgets »

ONEEYEMAN wrote: Or you could just retrieve the combo box and add/remove the values as you can see fit.
Well, retrieving the values from the combo box would be the preferred way, if I could figure out how to get them all .
That's the reason for my question :oops:
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxGrid - retrieve all cell combo box values

Post by ONEEYEMAN »

Hi,
Did you see this?

Thank you.
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: wxGrid - retrieve all cell combo box values

Post by Widgets »

What specifically are you pointing to?
I have reviewed the documentation, but did not find what I needed.
If you were referring to

Code: Select all

virtual wxString wxGridCellEditor::GetValue  (  ) const 

Returns the value currently in the editor control. 
then it won't do what I need. I want all values, not just the currently selected one.
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxGrid - retrieve all cell combo box values

Post by doublemax »

The actual controls of grid editors have a short lifetime. They are only created when you start editing a cell and destroyed immediately afterwards.

For a wxGridCellChoiceEditor you can set the list with SetParameters(), but there is no way to read it. For the functionality you're describing, you'll have to derive your own class from wxGridCellChoiceEditor.
Use the source, Luke!
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: wxGrid - retrieve all cell combo box values

Post by Widgets »

Thank you very much for clarifying this issue. It was this same conclusion I came to and asked the question to confirm my findings.
However, deriving my own class just for this seems way too much work :-)

Instead, I am now simply saving the necessary data outside of the list at the same time I am creating the grid, so that I can then retrieve the strings without having to reread the configuration file they came from.
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
Post Reply