Table of Contents

Method EnsureChild

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

EnsureChild<T>(string?, Action<T>?, Action<T>?, EnsureSideBarChildFlags)

Ensures that a child control of the specified type exists within one of the tabs.

public virtual T EnsureChild<T>(string? title = null, Action<T>? onCreate = null, Action<T>? onUpdate = null, TabControl.EnsureSideBarChildFlags flags = EnsureSideBarChildFlags.None) where T : AbstractControl, new()

Parameters

title string

An optional title to associate with the child control if a new instance is created.

onCreate Action<T>

The action to execute when creating the child control.

onUpdate Action<T>

The action to execute when updating the child control.

flags TabControl.EnsureSideBarChildFlags

The flags for additional options.

Returns

T

An instance of the specified type T. If a child of this type already exists, it is returned; otherwise, a new instance is created, added to the collection, and returned.

Type Parameters

T

The type of the child control to ensure, which must derive from AbstractControl and have a parameterless constructor.

Remarks

This method checks the existing collection of child controls and returns the first instance of the specified type T if found. If no such instance exists, a new instance is created, optionally associated with the provided title, and added to the collection.