Table of Contents

Method EnsureChild

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

EnsureChild<T>(SplitPanelPosition)

Ensures that the specified panel position contains a child of the specified type.

public virtual T EnsureChild<T>(SplitPanelPosition position) where T : AbstractControl, new()

Parameters

position SplitPanelPosition

The position of the panel where the child control should be ensured.

Returns

T

An instance of the specified child control type T. If the panel already contains a child of the correct type, that instance is returned; otherwise, a new instance is created and returned.

Type Parameters

T

The type of the child control to ensure. Must be a subclass of AbstractControl and have a parameterless constructor.

Remarks

This method checks if the panel at the given position already has a child of the specified type. If not, it creates a new instance of the type T and assigns it as the child. If a child of a different type is present, an exception is thrown.

Exceptions

InvalidOperationException

Thrown if the panel at the specified position already contains a child of a different type than T.