protected virtual void InitializeTemplate()
Protected Overridable Sub InitializeTemplate
protected:
virtual void InitializeTemplate()
abstract InitializeTemplate : unit -> unit
override InitializeTemplate : unit -> unit
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.
// 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();
}
' Template control constructor
Public Sub New()
' This call is required by the Windows.Forms Form Designer.
' At runtime, actual initialization is deferred until needed.
If Me.DesignMode = True Then
InitializeComponent()
End If
End Sub
' Designer-generated initialization code
Private Sub InitializeComponent()
' ... Designer code goes here
End Sub
' Deferred initialization
Protected Overrides Sub InitializeTemplate()
' Create the contained controls
Me.InitializeComponent()
' Use the shared data source for the combo box
cboState.DisplayMember = "State"
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.
Me.ChangePolicyModified()
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.