Grid with button-type cell 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
xalgor
In need of some credit
In need of some credit
Posts: 9
Joined: Wed Dec 17, 2008 8:31 am

Grid with button-type cell

Post by xalgor » Wed Dec 17, 2008 8:38 am

Hello,
can you help me to create such button-type cell?


Image

JimFairway
wxWorld Domination!
wxWorld Domination!
Posts: 1059
Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada

Post by JimFairway » Wed Dec 17, 2008 6:08 pm

Hi,

If you're okay with using a pop up menu rather than a drop down list, then:

Define your own wxGridCellRenderer for that cell (see the wxGrid sample). Use the renderer to add the icon to the font text.

Make the cell read-only, then catch the EVT_GRID_CELL_LEFT_CLICK event and display a pop-up menu.

If you go this route, you can do a few simple calculations to align the pop-up menu with the grid cell so it always shows in the same relative area on the grid.


Hope that helps,

Jim
OS: Vista SP1, wxWidgets 2.8.7.

xalgor
In need of some credit
In need of some credit
Posts: 9
Joined: Wed Dec 17, 2008 8:31 am

Post by xalgor » Thu Dec 18, 2008 8:52 am

JimFairway wrote:Hi,

If you're okay with using a pop up menu rather than a drop down list, then:

Define your own wxGridCellRenderer for that cell (see the wxGrid sample). Use the renderer to add the icon to the font text.

Make the cell read-only, then catch the EVT_GRID_CELL_LEFT_CLICK event and display a pop-up menu.

If you go this route, you can do a few simple calculations to align the pop-up menu with the grid cell so it always shows in the same relative area on the grid.

Jim
Thank you, Jim, I'll try.

framepointer
Super wx Problem Solver
Super wx Problem Solver
Posts: 264
Joined: Mon Aug 07, 2006 3:25 pm
Location: Baia Mare, Romania
Contact:

Post by framepointer » Thu Dec 18, 2008 10:09 am

Hi.

You could put a floating wxButton on top of the grid. Just create a button using the grid as parent.
Hide the button for the moment.
Catch EVT_GRID_CMD_SELECT_CELL:
1) If the cell allows the button show the button
2) Hide the button if the cell does not allow it

Another approach would be using
EVT_GRID_EDITOR_HIDDEN
EVT_GRID_EDITOR_SHOWN

Catch both events and show a custom editor maybe.

I'm not familiar with wxGRID. I just told what I would try first :)

Regards
Software is like sex,
It's better when it's free.
~Linus Torvalds

xalgor
In need of some credit
In need of some credit
Posts: 9
Joined: Wed Dec 17, 2008 8:31 am

Post by xalgor » Thu Dec 18, 2008 11:21 am

Jim,
I need a standard button, not custom bitmap. I don't understand how to do this using CellRenderer.

xalgor
In need of some credit
In need of some credit
Posts: 9
Joined: Wed Dec 17, 2008 8:31 am

Post by xalgor » Thu Dec 18, 2008 12:59 pm

framepointer wrote:Hi.

You could put a floating wxButton on top of the grid. Just create a button using the grid as parent.
I create it, but I don't see it when i run application :(

xalgor
In need of some credit
In need of some credit
Posts: 9
Joined: Wed Dec 17, 2008 8:31 am

Post by xalgor » Fri Dec 19, 2008 8:40 am

wxPropertyGrid is the answer!
http://wxpropgrid.sourceforge.net/

bloodlee
Experienced Solver
Experienced Solver
Posts: 77
Joined: Thu Nov 30, 2006 10:49 am
Location: Shenzhen, CHN

Post by bloodlee » Fri Dec 26, 2008 6:49 am

Good component!
Thanks.

Post Reply