Grid renderers rationale

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.
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 370
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Grid renderers rationale

Postby raananb » Fri Jul 13, 2018 9:15 am

wxGrid::SetCellValue expects a wxString as a value to place int the cell.

When I assign a wxGridCellFloatRenderer to a cell, it means that I intend to have a value of float (double) displayed in the cell. However, the float value must be converted to a wxString to be accepted by SetCellValue.

I dont see the added value (no pun intended) of the renderer if I must first convert the float value to a wxString, since wxString::Format can achieve the same effect as a renderer.

I would have thought that if I assign a Float renderer to a cell, then the SetCellValue would accept a float value IN MY CODE, and quietly use the renderer to make the necessary conversion. Would overloading SetCellValue be the answer?

Am I missing something?

User avatar
doublemax
Moderator
Moderator
Posts: 12818
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Grid renderers rationale

Postby doublemax » Fri Jul 13, 2018 1:11 pm

I guess it only makes sense if you use a custom wxGridTableBase as data model, the default model only stores strings.
http://docs.wxwidgets.org/trunk/classwx ... _base.html

There you have SetValueAsDouble and a few more options.
Use the source, Luke!

raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 370
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: Grid renderers rationale

Postby raananb » Fri Jul 13, 2018 1:38 pm

Got it.
Thanks.


Return to “C++ Development”

Who is online

Users browsing this forum: Artifact2238, Bing [Bot] and 23 guests