How to: Show long text in a list
Show long text, such as a change log in JSON, an SQL statement, or a multiline comment, in a column of
a WklGrid, WklTreeList, or WklGantt without making every row tall: the cell shows the first line,
and a zoom box shows the full text.
Requires WKL Forms Object Library 1.43 or later.
Solution overview
Editor = wedMemoon the column: the cell shows the first line that contains text, plus a marker (⋯) if there's more.- The zoom box opens on a double-click, F2, Shift+F2 (the Access Zoom shortcut), or Enter; it shows the full text as read-only so that users can select and copy it. Esc or Enter closes it.
Monospace = Truefor code, JSON, or SQL: the cell and the zoom box use a fixed-width font, and long lines in the zoom box keep their shape and scroll horizontally.
Implementation
A grid named Grid1 over an audit table with the columns Timestamp, UserName, Statement (SQL),
and Change (JSON):
' Form_Load of the form with the grid.
With Me!Grid1.Object
.Columns("Statement").Editor = wedMemo
.Columns("Statement").Monospace = True
.Columns("Change").Editor = wedMemo
.Columns("Change").Monospace = True
End With
Remarks
- Read-only. A memo cell is never edited in place, regardless of
ReadOnly; if the text needs to change, edit it in a form (EditForm). - Full text everywhere else. Search, copying a cell, export, and screen readers get the full text, not just the first line.
- In a list with an edit form, the memo cell still opens its zoom box; the other cells open the form.
- Text as stored. The zoom box doesn't reformat JSON or SQL, so store the text indented if it should be read indented.
Related topics
en/wiki/msaccess/comctl/how-to/show-long-text-in-a-list.txt · Zuletzt geändert: von Wolfgang van der Stille