Force user to select a value in wxGrid before editing cells

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
Knows some wx things
Knows some wx things
Posts: 31
Joined: Sun Nov 07, 2010 5:19 pm

Force user to select a value in wxGrid before editing cells

Post by Nico » Mon Nov 12, 2018 9:41 pm


I have created a wxGrid and in column 0 I have created a selection option using wxGridCellChoiceEditor. This works very nice.

Now I want to implement what should happen if somebody modifies a value in the grid. For most positions this seems to be rather straight forward, they already have a value and I just need to get the new value as a wxString.
However in my application it is important that the user selects a value in the first column before any of the other cells are edited. I don't think it will be safe to trust the user in this respect, so I would like to make it user-proof.

I can think of two ways to do this:
1. if one of the other columns (of a row where no value has been selected in the first column) is selected, the selected cell is moved to the first column and the wxGridCellChoiceEditor is popped-up to enable the user to make a choice.
2. for any row that does not have a value selected in the first column, the cells of all other columns are gray and can not be selected/edited.

Personally I would prefer the first approach, but I can't find if it is possible to make this happen from the code. If it is not possible, the second approach would be an alternative, but then I would be in need of an effective way to activate and deactivate the cells in the other columns.

I hope somebody here has some advise about how to make this user-proof.

Kind regards, Nico

Post Reply