WxGrid questions
-
- Experienced Solver
- Posts: 74
- Joined: Thu Sep 25, 2014 7:40 pm
WxGrid questions
1) Is there some way to disable all group selection functions? I want to disallow the user from ever having more than one cell selected. For my purposes, the selected cell is the "active item", and it makes no sense for there to be more than one active item.
2) Is there some way to change the color of the top and left grid lines if there are no row and column headers? In the attached image you can see that the lines between cells are red, as set by SetGridLineColour( wxColour( 255, 0, 0 ) ), but the top and left lines are not. I assume that this is because they are actually the right and bottom lines of what would be the row and column headers.
In my case, I am using a grid as an item selection method, and simply want the user to be able to select a single square where each square represents an object for them to choose from.
I am using wxWidgets 3.04 under VisualStudio 2017 - Windows 10.
Thanks.
2) Is there some way to change the color of the top and left grid lines if there are no row and column headers? In the attached image you can see that the lines between cells are red, as set by SetGridLineColour( wxColour( 255, 0, 0 ) ), but the top and left lines are not. I assume that this is because they are actually the right and bottom lines of what would be the row and column headers.
In my case, I am using a grid as an item selection method, and simply want the user to be able to select a single square where each square represents an object for them to choose from.
I am using wxWidgets 3.04 under VisualStudio 2017 - Windows 10.
Thanks.
- Attachments
-
- Untitled.png (3.06 KiB) Viewed 1669 times
Re: WxGrid questions
wxGrid might not be the best choice for what you're doing. How many cells are there at maximum? If there are not too many, you could work with individual controls (e.g. a wxPanel) as cells. Otherwise something custom might be better.
Use the source, Luke!
- shawnhcorey
- Knows some wx things
- Posts: 41
- Joined: Mon Nov 19, 2012 3:29 pm
- Location: The Great White North
Re: WxGrid questions
Wouldn't you have to use `wxGridSizer` or `wxFlexGridSizer` for layout of the `wxPanel`s?doublemax wrote:wxGrid might not be the best choice for what you're doing. How many cells are there at maximum? If there are not too many, you could work with individual controls (e.g. a wxPanel) as cells. Otherwise something custom might be better.
WARNING: Highly caffeinated . Approach with caution .
-
- Experienced Solver
- Posts: 74
- Joined: Thu Sep 25, 2014 7:40 pm
Re: WxGrid questions
Well, there could be anywhere from like 20 to 2000 (and I won't know how many until runtime).
I thought that by using the wxGrid I could gain a lot of functionality (like scrolling if needed).
It seems that wxGrid has MORE than what I need, I just want to enforce the "one-selected-cell-only" rule.
The top and left side line issue is not a big deal, just an aesthetic item.
I could do a custom control, but I would have to duplicate a lot of functionality I think.
I thought that by using the wxGrid I could gain a lot of functionality (like scrolling if needed).
It seems that wxGrid has MORE than what I need, I just want to enforce the "one-selected-cell-only" rule.
The top and left side line issue is not a big deal, just an aesthetic item.
I could do a custom control, but I would have to duplicate a lot of functionality I think.
Re: WxGrid questions
Hi,
According to this, such selection mode is not available, most likely because the control mimics the "spreadsheet" BEHAVIOUR.
But you can try to catch some events and disallow selection when it happens.
Thank you.
According to this, such selection mode is not available, most likely because the control mimics the "spreadsheet" BEHAVIOUR.
But you can try to catch some events and disallow selection when it happens.
Thank you.
Re: WxGrid questions
Ok, then using individual controls is not an option (at least not a good one).Well, there could be anywhere from like 20 to 2000 (and I won't know how many until runtime).
Can you describe in more detail what you actually need / what the control has to do?I could do a custom control, but I would have to duplicate a lot of functionality I think.
Use the source, Luke!
Re: WxGrid questions
Hi,
The other alternative is to use virtual list control.
But as doublemax said - we need to know what functionality should be there.
Thank you.
The other alternative is to use virtual list control.
But as doublemax said - we need to know what functionality should be there.
Thank you.
-
- Experienced Solver
- Posts: 74
- Joined: Thu Sep 25, 2014 7:40 pm
Re: WxGrid questions
Basically, I want to show a "grid-like" widget that has a programmable number of boxes. Each box represents an item in the world from 1 to N.
When the user clicks on a box, a frame to the right will be displayed containing the data associated with that item. The user can then view and/or edit that data, until such time as another box is clicked. The right-side frame then gets updated to show/edit the data of the newly selected item.
Functionally, I guess that it is sort of like a compact version of a wxChoice box, where the choices are 1 to N, but you don't have to scroll down through hundreds of items if the list gets long.
I have tried to do the obvious things, like various combinations of capturing wxEVT_GRID_CELL_BEGIN_DRAG and/or wxEVT_GRID_CELL_LEFT_CLICK, and doing a ClearSelection() but that has been either worthless or created a stack overflow due to recursive calls.
I would think that allowing only a single cell to be selected should be an easy thing. There are options for selecting a single row, or a single column, but not a single cell. Seems like an oversight to me.
I appreciate the help though, guys. Thanks.
When the user clicks on a box, a frame to the right will be displayed containing the data associated with that item. The user can then view and/or edit that data, until such time as another box is clicked. The right-side frame then gets updated to show/edit the data of the newly selected item.
Functionally, I guess that it is sort of like a compact version of a wxChoice box, where the choices are 1 to N, but you don't have to scroll down through hundreds of items if the list gets long.
I have tried to do the obvious things, like various combinations of capturing wxEVT_GRID_CELL_BEGIN_DRAG and/or wxEVT_GRID_CELL_LEFT_CLICK, and doing a ClearSelection() but that has been either worthless or created a stack overflow due to recursive calls.
I would think that allowing only a single cell to be selected should be an easy thing. There are options for selecting a single row, or a single column, but not a single cell. Seems like an oversight to me.
I appreciate the help though, guys. Thanks.
Re: WxGrid questions
That sounds simple enough for a custom control. All you need is a wxPanel with a custom paint event handler where you draw all the boxes according to their state (selected or not). Then in a mouse event handler you check which (if any) box was clicked, then you change its state, generate an event and force a refresh.
For the event you don't even have to define a new one, just re-use an existing one, e.g. wxEVT_LISTBOX.
For the event you don't even have to define a new one, just re-use an existing one, e.g. wxEVT_LISTBOX.
Use the source, Luke!
-
- Experienced Solver
- Posts: 74
- Joined: Thu Sep 25, 2014 7:40 pm
Re: WxGrid questions
Yeah, that's what I suspect that I'll end up doing.
It just seemed simpler at first glance to use a wxGrid, since it had everything I needed, except for single cell selection.
Thanks.
It just seemed simpler at first glance to use a wxGrid, since it had everything I needed, except for single cell selection.
Thanks.