Before QM 2.3.2, this control was almost undocumented. Some samples were in the forum. In QM 2.3.2 it is documented, easier to use, and has many enhancements:
The control can be used in dialogs and other windows to:
Use Dialog Editor. It also allows you to define style and columns.
You also can define style and columns at run time. Use class DlgGrid. See function sample_Grid.
Dialog Editor generates code that includes variables for grid controls. Before calling ShowDialog, assign a string in CSV format to a grid variable. To load and process CSV, use ICsv interface.
You can also set data using class DlgGrid. See function sample_Grid.
When ShowDialog returns on OK, the variable contains string in CSV format. To process and save it, use ICsv interface.
You can also get data using class DlgGrid. See function sample_Grid.
Use class DlgGrid. See function sample_Grid.
Also you can use grid control and list view control (SysListView32) messages, notifications, types and constants.
Grid control messages etc are documented below, in grid.h. In QM they are declared in reference file GRID. Use like this: GRID.LVN_QG_COMBOFILL.
List view control messages etc are documented in MSDN Library. They are declared in reference files WINAPI and WINAPIV.
In dialog procedure use functions of class DlgGrid.
If the grid has style "Can be set row control type" (QG_SETROWTYPE), you also can set row control types when adding text. Use syntax: <type>text in first column cells. Read more below, in Details.
In dialog procedure use functions of class DlgGrid.
To add icons, at first create imagelist with QM imagelist editor. It is in code toolbar. It also can create code to load the imagelist. In dialog procedure, load the imagelist (__ImageList.Load), attach it to the control (DlgGrid.SetImagelist), and assign icon indices (DlgGrid.RowPropSet or DlgGrid.RowAddSetX).
If the grid has style "Can be set row control type" (QG_SETROWTYPE), you also can set these properties when adding text. Read more below, in Details. See function sample_Grid_images.
It is easy with sqlite databases. Use Sqlite class. It can display table in grid control. See function sample_Grid_Sqlite.
To use with other database types, use Database and DlgGrid classes. Currently there are no functions that would transfer whole table from/to database to grid control. You will have to do it for each row.
QM grid control lives in a QM dll qmgrid.dll. It is not available on computers where QM is not installed.
You can add the dll to exe. Add this line somewhere near the beginning of exe code:
ExeQmGridDll
When creating exe, it adds qmgrid.dll to exe resources. At run time it extracts to the temporary folder and loads.
If you don't want to add the dll to exe: take qmgrid.dll from QM folder; add to a zip file or setup program together with exe; on other computers extract them to the same folder. If you use grid controls in a dialog or with CreateControl, exe loads the dll when need. Else load the dll with LoadLibrary.
The class name is QM_Grid. Implemented in qmgrid.dll.
If grid control has "Can be set row control type" style (GRID.QG_SETROWTYPE, 4):
1. When you set control type of the first cell in a row, it also sets control type for other cells in the row.
2. When adding a row, you can specify row control type and/or other row properties in first cell's text.
Syntax:
<ctype/lparam/image/overlayImage/stateImage/indent/ctypes>text
ctype - row control type. See below.
lparam - a user-defined int value. Or can be any string.
image - image index. Use -1 for no image.
overlayImage - overlay image index.
Valid values are 1 to 15. Index 0 will not add overlay image.
Overlay images are drawn transparently over normal images.
To define overlay images, use __ImageList.SetOverlayImages or ImageList_SetOverlayImage with the main imagelist.
stateImage - state image index.
Valid values are 1 to 15. Index 0 will not add state image.
The index is 1-based, therefore index 1 will display image 0 from the state imagelist.
State images are drawn in the space reserved to the left from normal images.
Must be set state imagelist or checkboxes style.
If checkboxes style, use stateImage 1 and 2 for unchecked and checked.
indent - indent. It is number of image widths. Valid values are -1 to 254.
ctypes - list of cell control types. Use . to inherit from ctype or column. Use -1 to inherit from column. Example: .0 -1..2
All parts are optional. For example, can be <ctype>text, or <//image>text.
All numbers must be simple numbers, not constant names or expressions.
To display images and indent, imagelist must be set. Use DlgGrid.SetImagelist.
Row properties also can be set/retrieved using DlgGrid functions.
If style "User cannot edit first column" (GRID.QG_NOEDITFIRSTCOLUMN, 1) also is set, will not remove the <...> string. Just will not display it.
0 | edit. |
1 | combo. |
2 | check. |
3 | date. |
7 | read-only. |
8 (0|8) | edit multiline. |
9 (1|8) | combo sorted. |
11 (3|8) | time. |
16 (flag) | with button. |
23 (7|16) | read-only edit + button. |