Controls.Add

Syntax:

Add(<Type>, <Name>, <Visibility>, <MoveTo>)

Parameters:

<Type> (required)

Type: Type.
Type of control added:
ProgressBar; CalendarBox; Button; CommandBar; Label; Panel; RadioButton; SpreadsheetDocumentField; HTMLDocumentField; TextDocumentField; TextBox; ComboBox; ListBox; PictureBox; TrackBar; Splitter; GroupBox; TableBox; CheckBox; GraphicalSchemaField; GeographicalSchemaField.

<Name> (required)

Type: String.
Name of control to be created. The name should be set in accordance with 1C:Enterprise 8 naming rules. Otherwise execution of the method will results in calling the exception.

<Visibility> (optional)

Type: Boolean.
Defines whether to create a new form control element as visible or not. True - element is created as visible;
Default value: True.

<MoveTo> (optional)

Type: Panel; SpreadsheetDocumentField.
Defines to which form panel or spreadsheet document the element created belongs. If a panel is indicated, then the added element is positioned on the current page of the panel. If not specified, the element created will belong directly to the form.

Returned value:

Form control.

Description:

Add control to form.

Availability:

Thick client.

Example:

// Let's place a tablebox on a page
RegisterField = Controls.Add(Type("TableBox"), 
        TableRow.Name, 
        True
, 
        Controls.MainPanel);
RegisterField.Data = "DocumentObject.RegisterRecords." + TableRow.Name;

If 
NOT IsNew() Then
    RegisterFileld.Value.Read();
EndIf
; 

RegisterField.Top = 30;
RegisterField.Left = 6;
RegisterField.Width = Controls.MainPanel.Width - 14;
RegisterField.Height = Controls.MainPanel.Height - 56;
RegisterField.ReadOnly = False;
RegisterField.ChangeRowOrder = True;
RegisterField.ChangeRowSet = True;

RegisterField.SetLink(ControlEdge.Top,
        RegisterCommandPanel,
        ControlEdge.Bottom);
RegisterField.SetLink(ControlEdge.Bottom,
        Controls.MainPanel,
        ControlEdge.Bottom);
RegisterField.SetLink(ControlEdge.Right,
        Controls.MainPanel,
        ControlEdge.Right);

RegisterField.CreateColumns();

If 
Metadata.AccumulationRegisters[TableRow.Name].RegisterType =     Metadata.ObjectProperties.AccumulationRegisterType.Balance Then

    KindOfMovementColumn = RegisterField.Columns.Insert(1, "Records  type");
    KindOfMovementColumn.Name = "AccumulationRegisterRecordsType";
    KindOfMovementColumn.SetControl(Type("TextBox"));
    KindOfMovementColumn.Data = "RecordType";
    KindOfMovementColumn.Control.ChoiceButton = True;
    KindOfMovementColumn.Control.ChooseType = False;

EndIf
;

RegisterField.Columns.Recorder.Visible = False;
RegisterField.Columns.Period.Visible      = False;
RegisterField.Columns.LineNumber.Visible = False;


    

1C:Enterprise Developer's Community