Applies To: | Grid | ListView |
Description
If enabled, this event is reported when the user changes the width of a column in a Grid or ListView object, or changes the width of the row titles in a Grid. This may be done by dragging a border with the mouse or by double-clicking over a border. In the former case, the default action is to adjust the width of the appropriate column or the width of the row title area to the size selected by the user. In the latter case, the default action is to adjust the width to the maximum required to display all the data.
In either case, you can disable the default action by setting the event action code to ¯1 or you can selectively prevent a particular resize operation from taking place by returning 0 from a callback function.
The event message reported as the result of ⎕DQ, or supplied as the right argument to your callback function, is a 5-element vector as follows :
[1] | Object | ref or character vector |
[2] | Event | 'SetColSize' or 176 |
[3] | Column number | Integer. This is sensitive to the index origin, ⎕IO, but is ¯1 if the user has resized the row titles in a Grid. |
[4] | Width | Integer containing the value of the (new)column width. This is ¯3 if the user has double-clicked to request automatic width adjustment. |
[5] | Undo flag | 0 or 1 |
You can resize a column or resize the row titles under program control by calling SetColSize as a method. If you specify ¯1 as the Width parameter, the column will be resized to its default width .. If you specify a value of ¯2 the column will be resized to fit the data. The following expression will size the first NCOLS columns of a Grid called F.G to fit the data and the column titles:
{F.G.SetColSize ⍵ ¯3}¨⍳NCOLS
The Undo flag is applicable only to a Grid object and is always 1 if the event was generated by the user.