About the FormComponent object

Each form contains a collection of components. The FormComponent object can be used to access individual components.

When you assign the FormComponent object to a variable, use the type IWSFormComponent.

A component on the currently active form can be accessed using the following code:


   '  Assign the component named "MyComponentName" to oMyComponent
   Dim oMyComponent As IWSFormComponent
   oMyComponent = ThisForm.Components("MyComponentName")

Accessing the value of a component

A component's value can be retrieved or set using the Text property. The following code sets an edit component's value to "New Value."


   '  Set the value of MyEditComponent to "New Value"
   ThisForm.Components("MyEditComponent").Text = "New Value"

In most cases, it is easier to work directly with IDO item values rather than components to retrieve and manipulate values.

Setting component attributes

Most component properties, including default value, read-only property, visible property, and required property, can be set programmatically. The following code makes a component read-only.


   '  Make MyComponent read-only
   ThisForm.Components("MyComponent").Enabled = False

Processing grid components

There are a number of special methods that can be used to process grids. You can retrieve and assign grid column values using GetGridValue and SetGridValue methods. The following code retrieves the value of the cell at row 1 and column 2.


   '  Assign the value of the cell at row 1 and col 2
   '  to strGridValue
   strGridValue = ThisForm.Components("MyGrid").GetGridValue(1, 2)

Alternatively, you can use the GetGridValueByColumnName and SetGridValueByColumnName methods to access a grid cell by column name instead of column number. The following code assigns a value to the cell at row 2 of the column named MyColumn.


   '  Assign the value at column "MyColumn" and row 2
   '  to "New Value"
   ThisForm.Components("MyGrid").SetGridValueByColumnName(2, "MyColumn", "New Value")

Methods and properties

See FormComponent object.