If you add controls without using the form wizards, you often need to change some of the properties of these controls. Even if you did use a wizard, you may want to change some of the properties to meet specific requirements that the wizards cannot provide.

Changing the Name and Caption of a Control

Every control has an ID and a Name. Controls that display data also have a SourceExpr property which is a C/AL expression. This can just be the name of a table field name or it can be a complex expression, perhaps with a field as an operand. When you use a form wizard or the Field Menu to create a text box that has a direct relationship to a table field, the Name and Caption are set by default to the name of the table field (unless the table field has a Caption, in which case this Caption is used). The label has a Caption derived from the Caption of the parent control (the text box). You can supply a Caption in either place if you want to have a different, perhaps more descriptive text than the field name as a caption. Be aware of the following dependencies:

  • If you change the Caption property of the text box, the Caption property of the label is set to this value as a default (displayed in angle brackets). If you change the text box Caption property again, the Caption property of the label is also changed again.

  • If you change the Caption property of the label directly, the value you enter is displayed without angle brackets, signifying that it is no longer a default value. Now if you change the property of the text box again, the value here is not updated.

Changing an Unbound Control into a Bound Control

An unbound text box, or other data control, can be easily changed to a bound control. You need to change the SourceExpr to the one that you want. If it is the name of a field in the database table, the values for Name and Caption automatically default to the standard values of the bound control, that is, they default to the name of the table field. This will not automatically add a label to the text box. If you want to change the source expression so that it refers to a field from another table, you must enter a more complex C/AL expression.

Adding a Label to a Text Box

If you create a bound text box by changing the SourceExpr of an unbound text box, the bound text box does not automatically get an attached label. You can add a label by adding a label control to the form and then changing the ParentControl property of the label from the default (undefined) to the ID of the text box. You can see the ID of the text box in the first line of the Properties window for the text box. The control branch resulting from this operation can be selected and moved like other controls.

See Also