gbGrid
gbGrid is a dual-purpose application. It provides a full-featured, CSV/PSV editor. It also demonstrates the use of a standard ListView control as a fully editable grid with Excel-like cell navigation and selection capabilities. gbGrid provides multiple editing options - inplace editing, fixed place
editing and a popup record editor.
I've prepared the following short, online tutorial videos to help you get started with gbGrid.
To install, just unzip the contents of the distribution file into a folder of its own!
Feature List
gbGrid provides a wide variety of features, designed to emulate Excel spreadsheet selection,
navigation and editing features. Most actions can be accomplished by keyboard or mouse.
Cell Selection
- Single cell selection
- User-specified background color for selected cells
- Separate colors when ListView is in/out of focus
- Current cell drawn with border
- Cell block selection (rectangular cell range)
- Multiple cell block selection (non-contiguous)
- Single cell click unselects all other cells
- Row/Column selection
Mouse Navigation/Selection
- Click to select cell and to erase all other selections
- Shift click/drag to extend cell block selection
- Control click/drag to add new cell block to the selection list
KeyBoard Navigation
- Navigation by Up/Down/Left/Right arrows
- Navigation by Home, End, Ctrl-Home, Ctrl-End
- GoTo Cell
- ENTER configurable for use as down arrow
- Ensure visibility of selected cell
Single-Cell Editing
- InPlace, Fixed Place, and Edit Record dialog editing options
- Mult-line cell value editing (Edit Record only)
- User defines default editing option
- Accelerators keys allow overriding default editing option
- Real time display of editing results in cell
- Initiate editing with F2, Ctl-E, ENTER, double-click
- Complete edit with ENTER
- Cancel editing with ESC, ENTER or clicking outside the editor
- Canceling edit restores cell values
- Move to fixed editor with TAB, shift-TAB or mouse click
Multi-Cell Actions
- Cut/Copy/Paste/Delete
- Insert Date/Time
- Format as number or currency
- Fill cells using row/col content
- Select Rows/Cols
- Delete Rows/Cols
- Insert Rows/Cols
Cell Editing
Individual cells may be edited in gbGrid at any of three locations:
- InPlace - in the grid at the cell location
- Fixed Place - editor located just above the Statusbar
- Edit Record Dialog - popup dialog for editing a row of cells (handles multi-line content)
There are a variety of ways to initiate cell editing. The following keyboard and mouse actions
will initiate cell editing in the default editor, as set in the gbGrid toolbar.
- F2
- Ctl-E
- Dbl-Click the cell
- ENTER
If the user sets ENTER to act as the down arrow, it cannot be used to initiate cell editing.
Regardless of the default editing location, these additional commands are available
to initiate cell editing at a location of choice:
- Ctl-I - initiate InPlace Editing
- Click on the Fixed Place editor
- Ctl-R - open the Edit Row editor
Inplace and Fixed Place cell editing may be closed in the following ways.
- ENTER - saves changes
- ESC - loses changes
- Click outside the edit location - loses changes
- Cancel Edit (Toolbar) - loses changes
The Edit Record dialog can be closed with one of the following:
- Exit & Save - saves changes
- Exit w/o Save - loses changes
- "X" on caption - loses changes
- ESC - loses changes
- Alt-F4 - loses changes
Undo
gbGrid offers only a limited form of Undo. When the Cut/Delete, Insert Date/Time, Number/Currency,
and Fill All/Right/Down commands are issued, the modified cell block is saved to the Undo
queue. The location of the cell block is not stored in the undo queue, so it is up to the user
to make sure, before using Undo, that the currently selected cell is where the undo action
is to take place. Undo is effectively a paste of the Undo queue.
Once Undo is applied, the undo queue is cleared.
I suggest using Undo immediately after executing Cut/Delete, Insert Date/Time, Number/Currency,
or Fill All/Right/Down commands.
Multi-Line Values
Cells can contain multiple lines of text. The InPlace and Fixed Place editors, however, can
only display the first line of text. The Edit Record dialog can display, and edit, all lines of
text in a cell.
The Inplace and Fixed Place editors will display the first line only of a multi-line cell value,
but will display " ..." at the end of the line to indicate that additional, unseen, information
is available.
If used to edit a multi-line cell value, the InPlace and Fixed Place editors will truncate the
additional lines.
Here's an image showing the selected cell "Superman ...", where the "..." means there are multiple
lines of text. The popup Edit Record dialog is displayed, showing the multiple line of text.
In the actual cell value (i.e., in the data file), each of the lines much be separated by $DQ+$LF+$DQ,
which is the line feed surrounded by double quotes.
Toolbar
Many gbGrid features and settings are accessed through the toolbar buttons.
- Open - Open an existing source code file
- SaveAs - Save source code to a new file
- Reload - Reloads current file (loses all changes)
- Cut - Copy, then erase, all selected cells
- Copy - Copy all selected cells to the clipboard
- Paste - Paste clipboard content at selected cell
- Delete - Erase content of all selected cells
- Undo - Restores most recently selected cut, delete, or formatting action
- Search - Opens Find & Replace dialog
- Visible - Scrolls gird to ensure visibility of selected cell
- UnSort - Restores grid content to its original, unsorted order
- InPlace - Sets InPlace as default editing option
- Fixed - Sets Fixed Editor as default editing option
- Dialog - Sets Edit Record dialog as default editing option
- Font - Display Select Font dialog
- Print - Print selected cells
- Settings - Displays summary information about grid and it's content. Also provides
a dropdown menu with the following options:
- Set Focus Color - Sets color of selected cells when ListView has focus
- Set non-Focus Color - Sets color of selected cells when ListView does not have focus
- Set Edit Color - Set color of inplace and fixed text editors
- Sort Original Data - Sorts the original data to the current column sort criteria.
- Enable Colors - Toggles between all-white and user-defined color schemes
- ENTER as Down Arrow - Toggles use of ENTER as down arrow
- Monitor File Changes - Alerts user if file was changed externally during gbGrid session
- Fixed Edit Always Visible - Provides the option to hide the Fixed Place editor
- Fixed Editor Above Grid - Toggles location of Fixed Place editor above or below the grid
- Help - Opens this online Help page. Also provides a dropdown menu with the following options:
- Local Help - Opens a Help dialog with key Help information
- Video Tutorial #1 - Introduction
- Video Tutorial #2 - Cell Navigation
- Video Tutorial #3 - Multi-Cell Editing
- Video Tutorial #4 - Single Cell Editing
Context Menu
Two grid context menus are provided, one for the header and one for the client area of the ListView.
Header Context Menu
Right click on any ListView column header to get this context menu:
- Select Col - select all cells in the column
- Insert Col - insert a column to the left
- Delete Col - delete the selected column
- Set Header Text - opens popup text entry box to enter the new column header text
ListView Context Menu
Right click on any of the cells to get this context menu:
- Cut Selected Cells - Erases all selected cells, places erased content on clipboard
- Copy Selected Cells - Copies all selected cells to the clipboard
- Delete Selected Cells - Erases all selected cells
- Paste - Pastes clipboard content at current cell (first found cell block only)
- Format ... - Provides options to modify selected cells - insert date/time and format as numbers/currency
- Fill ... - Provides row-down, column-right and corner-all fill (copy) actions
- Rows ... - Provides Select/Insert/Delete options for rows in current cell block
- Columns ... - Provides Select/Insert/Delete options for rows in current cell block
- Sum Selected Cells - Displays sum of selected cells. Also places results on clipboard.
Key Actions
The following keyboard actions are supported:
- Arrow Keys - Move current cell one cell in selected direction
- ENTER - Move current cell down or enter edit mode, depending on settings
- DEL - Erases content of all selected cells
- Home - Selects the first cell in the current row
- End - Selects the last cell in the current row
- Ctrl-Home - Selects the first cell in the grid (upper-left)
- Ctrl-End - Selects the last cell in the grid (lower-right)
- PageUp - Scrolls one page up, selects single cell
- PageDown - Scrolls one page down, selects single cell
- Shift-PageUp - Scrolls one page up, selecting cells between current cell and new cell
- Shift-PageDown - Scrolls one page down, selecting cells between current cell and new cell
- Ctrl-Space - Selects column containing the current cell
- Shift-Space - Selects row containing the current cell
- Ctrl-A - Selects all cells
- TAB - Moves to next control in TAB order
- Shift-TAB - Moves to previous control in TAB order
Mouse Actions
The following mouse actions are supported:
- Click/drag - select cell, create new cell block, unselect all other cells
- Double-click - initiate edit action (Inplace or Fixer editor, per user settings)
- Shift- click/drag - add contiguous cells to current cell block
- Control-click/drag - create/resize new cell block
Keyboard Shortcuts
The following key combinations are available to the user to access gbGrid features:
- F1 - Help
- F2 - Activate cell edit
- F3 - Display Find & Replace dialog
- Ctrl+C - Copy selected cells to clipboard
- Ctrl+D - Toggle use of ENTER for navigation
- Ctrl+E - Activate edit
- Ctrl+F - Display Find & Replace dialog
- Ctrl+G - GoTo cell
- Ctrl+I - Initiate InPlace Editing
- Ctrl+K - Cancel Edit
- Ctrl+O - Display Open file dialog
- Ctrl+P - Toggle edit InPlace
- Ctrl+R - Open the Edit Record dialog
- Ctrl+S - Save As
- Ctrl+V - Paste clipboard to current cell
- Ctrl+W - AutoSet Column Widths to match content
- Ctrl+X - Cut selected cells (copy to clipboard then erase)
- Ctrl+Z - Undo
gbGrid Limitations
gbGrid is not a control. So you cannot simple use Control Add to incorporate
it into your application. Further, the current version of gbGrid supports only
one grid per application. I'm reasonably sure it's possible to modify the code
to handle both limitations, but I've not tried to take the code that far.
There are also some Excel features which gbGrid does not provide. These are not
high on my godo list!
- Multiple "sheets"
- Cell Equations
- Named Cells
- Freeze Panes
- Hide Rows/Columns
Of course, if I (or someone else) come up with a suggestion that would be easy
or straightforward to implement, I've been known to be easily distracted! Creation of a
control might especially be a task of interest, as I've never written a control before.
gbGrid GoDo List
This list of items are features I'd like to add, but just haven't gotten around
to them yet.
- Unlimited Undo
- Draw box around each cell block
- Drag cell block box to copy/move content
- Row headers
- Set header colors current cell
- A-Z column header option (instead of using 1st line of CSV file)
- Remove all cell blocks except the one under a mouse click
- Inset/Delete cells then move cells up/down as in Excel
- "Replace All" in Find and Replace dialog
- "Save" menu option (SaveAs is what is now available)
Other Comments
Comments and suggestions are welcome!