Adding combobox to a wxGrid 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
mazeem3
Earned a small fee
Earned a small fee
Posts: 17
Joined: Fri Jul 14, 2017 6:12 pm

Adding combobox to a wxGrid

Post by mazeem3 »

I have a wxGrid created im trying to add a combobox to my grid

Code: Select all

static const wxString severities[] =
{
    wxT("wishlist"),
    wxT("minor"),
    wxT("normal"),
    wxT("major"),
    wxT("critical"),
};

grid = new wxGrid(this,ID_GRID,wxDefaultPosition,wxDefaultSize);
grid->CreateGrid(1,13); // must call this once in constructor to prevent segfault
grid->HideRowLabels();

grid->SetCellEditor(0, 1, new wxGridCellChoiceEditor(WXSIZEOF(severities), severities));
grid->SetCellValue(0, 1, severities[0]);

vbox->Add(grid,1, wxEXPAND | wxALL);
All this does is display the cell with the correct value but does not give me a combobox where I can change the value
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Adding combobox to a wxGrid

Post by doublemax »

That looks ok. The choice will only appear if you click twice into the cell. The first click will set the grid cursor to the cell, the second will switch into editmode and create the combobox.
Use the source, Luke!
mazeem3
Earned a small fee
Earned a small fee
Posts: 17
Joined: Fri Jul 14, 2017 6:12 pm

Re: Adding combobox to a wxGrid

Post by mazeem3 »

Thank you for the response. The code was correct but I had my grid set as

Code: Select all

grid->EnableEditing(false);
Which would cause the combobox to not work.
Post Reply