GridSetColumnLayout method (WinStudio scripts)

Applies to

IWSFormComponent interface

Description

This method allows user to set the visibility, order, and width of a grid column on a form.

Syntax

object.GridSetColumnLayout( string )

where string is ColumnName_1:ColumnWidthOrA_1; ColumnName_2:ColumnWidthOrA_2

Part Description
object Required. A reference to a form or grid component object.
string Required. A string that consists of semicolon-delimited pairs. Each pair is colon-delimited into two parts:
  • ColumnName: The name of the column component within the grid.
  • ColumnWidthOrA: Either the desired width of column in Char units or the letter "A" to set the column as auto-fit to its data.
    Note: Column widths are in Char units, the same units used by default for column width settings in the designer window.

Remarks

This method can be called from any event handler in the form’s life cycle in which the grid and other form components exist and can be modified.

This method is typically called in any of these events:

  • The StdFormPredisplay event, which covers the initial load of data to the form (assuming the form loads with data, unlike Filter in Place mode)
  • The StdObjectSelectCurrentCompleted event, which fires with each new record selection (by click, keyboard, or Previous/Next commands)
  • Button, ComboBox, and Menu item's primary event, when you arrange for multiple column layouts for the same grid. For example, a set of menu items can each call GridSetColumnLayout with a different input string, to effectively create a Views menu for the grid.
Note: 
  • This method can be used only with horizontal grid components.
  • When the grid’s Stretch Columns setting is True, this function will work as normal with one exception: the right-most visible column will stretch to fill the remaining space of the grid.
  • When Autofit is used on a column, the column’s width will change while scrolling vertically in the grid and will cause the columns to adjust to the currently visible content.

Example

Sub NarrowPropertiesView()
      Dim layout as String = "PropertyNameGridCol:20;ColumnNameGridCol:20;DataTypeGridCol:A"
      ThisForm.Components("PropertiesGrid").GridSetColumnLayout(layout)
End Sub