Example: Using the GridSetColumnLayout method

This example can be used for setting up grid columns on a form.

In this example, a user wants fewer columns on the Properties grid of the IDOs form to view the list of properties easier. The user follows these requirements:

  • Display the Property Name, Column Name and Data Type columns only, in this order
  • Column width of Property Name and Column Name is 20 Char
  • Column width of Data Type is set to auto-fit
  • Display this limited view as the form first opens

To set up this view, the user must perform these actions:

  1. Determine the component names of the grid and the columns to display.
    1. Open the IDOs form in Design Mode.
    2. Select the Properties tab.
    3. In the upper left corner of the grid component, click the Edit grid column(s) button.
    4. In the Edit Contained Components dialog box, determine the component names of the grid and the columns to display.

      Following the requirements, the user will use these component names:

      Requirement Component name
      Properties tab PropertiesGrid
      Property Name field PropertyNameGridCol
      Column Name field ColumnNameGridCol
      Data Type field DataTypeGridCol
    5. Click OK.
    6. Close the form.
  2. Set up the GridSetColumnLayout method's input string based on this format:
    "ColumnName_1:ColumnWidthOrA_1; ColumnName_2:ColumnWidthOrA_2"

    Following the requirements, the user will use this input string:

    "PropertyNameGridCol:20;ColumnNameGridCol:20;DataTypeGridCol:A"

    where:

    • ColumnName are PropertyNameGridCol, ColumnNameGridCol, and DataTypeGridCol, respectively.
    • ColumnWidthOrA are 20 and A, respectively.
  3. Set up the form script based on this syntax:
    ThisForm.Components(“componentName”)

    The new function is called with the input string, and placed into a Sub or Function. A Sub can be used, since there is no return value needed. A Sub can have any name. In this example the user will use NarrowPropertiesView:

    Sub NarrowPropertiesView()
          Dim layout as String = "PropertyNameGridCol:20;ColumnNameGridCol:20;DataTypeGridCol:A"
          ThisForm.Components("PropertiesGrid").GridSetColumnLayout(layout)
    End Sub 
    
  4. Create an event handler to call the method.
    1. Open the IDOs form in Design Mode.
    2. Select Edit > Event Handlers
    3. Click New.
    4. Specify this information:
      Event
      Select StdFormPredisplay.
      Type
      Select Form Script Method.
      Parameters
      Specify NarrowPropertiesView().
    5. Click OK.
    6. Close the form.
When the user opens the IDOs form, the Properties grid will only display the three required columns.

In the Windows client, users can also use the Edit Grid Column Visibility and Order dialog box to set up the grid column visibility and order. This dialog box can be used together with the GridSetColumnLayout method to further edit the layout, as needed.

In this example, when the user right-clicks on the upper-left corner of the Properties grid, and selects Edit Grid Columns..., the Edit Grid Column Visibility and Order dialog box is displayed. The dialog box lists all of the original columns, but only the first three columns are visible, and at the top of the order. The remaining columns are in the original order they had before the layout change was applied, except for the currently visible columns, which are moved to the top of the order as part of the layout change.

In the web client, the Edit Grid Columns... option is removed when the GridSetColumnLayout method is used.