Improving the Functionality of Comboboxes in wxGrid

The grid in wxWidgets allows you to insert a combobox in a cell, which is a feature that very few other toolkits offer. However, the default behaviour is somewhat lacking.

First of all, there is no visual indication of which cell has a combobox until the cell has focus. Then, when you click on a cell to edit it, you have to click three times: once to give the cell focus, once to activate the editor, and a third to actually open the combobox. That's very labor intensive for the poor user if you have several dozen cells to edit.

So, I wrote some classes to rectify these problems:

wxGridCellChoiceRenderer Displays the combobox buttons when not active
EzGrid Activates cells in the grid with just one click
wxFastComboEditor Opens the combobox immediately if you clicked on the button

To use this code, include the attached files in your project. Then, set the cell with the combobox something like this:

grid->SetCellRenderer(1, 1, new wxGridCellChoiceRenderer);
wxStringstrChoices[3] = {"one", "two", "three"};;
grid->SetCellEditor(1, 1, new wxFastComboEditor(3, strChoices, TRUE));
Notes:

ExGrid will put all cells, not just combobox cells, into edit mode with just one click. Normally, this is desirable because you can edit the cells quicker.

The code works under both Windows and Linux (wxGTK), except for the code that opens the combobox automatically. I'm not very experienced in GTK and I haven yet figured out how to send a left mouse click message to a control.



Downloads

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: March 27, 2014 Teams need to deliver quality software faster and need integrated agile planning, task tracking, source control, auto deploy with continuous builds and a configurable process to adapt to the way you work. Rational Team Concert and DevOps Services (JazzHub) have everything you need to build great software, integrated seamlessly together right out of the box or available immediately in the cloud. And with the Rational Team Concert Client, you can connect your …

  • A help desk is critical to the operations of an IT services business. As a centralized intake location for technical issues, it allows for a responsive and timely solution to get clients and their staff back to business as usual. In addition to handling immediate IT issues, a help desk performs several proactive tasks to ensure clients' IT systems remain operational and downtime is minimized. Thus, utilizing a help desk and following best practices can improve the productivity, efficiency and satisfaction of …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds