TemplateControlInitializeTemplate Method

This can be overridden to create and/or initialize controls in the template

Definition

Namespace: EWSoftware.ListControls
Assembly: EWSoftware.ListControls (in EWSoftware.ListControls.dll) Version: 2023.4.9.0
protected virtual void InitializeTemplate()

Remarks

This will not be called until the template is scrolled into view. This saves time and resources during the initial startup phase of a form that contains a data list control.

Overriding this method is optional. However, deferring initialization until it is required will save time and resources. The base version does nothing.

To be used, you should defer initialization in the constructor and call the InitializeComponent method in this override.

Example

C#
// Template control constructor
public RowTemplate()
{
    // This call is required by the Windows.Forms Form Designer.
    // At runtime, actual initialization is deferred until needed.
    if(this.DesignMode)
        InitializeComponent();
}

// Designer-generated initialization code
private void InitializeComponent()
{
    // ... Designer code goes here
}

// Deferred initialization
protected override void InitializeTemplate()
{
    // Create the contained controls
    this.InitializeComponent();

    // Use the shared data source for the combo box
    cboState.DisplayMember = cboState.ValueMember = "State";
    cboState.DataSource = dvStates;

    // Update control states based on the parent's change policy.
    // This can be omitted if you do not need it.
    this.ChangePolicyModified();
}

See Also