# UserControl

Namespace: **Wisej.Web**

Assembly: **Wisej.Framework** (4.0.0.0)

* [Control](/api/wisej.web/general/control.md)
  * [ScrollableControl](/api/wisej.web/containers/scrollablecontrol.md)
    * [ContainerControl](/api/wisej.web/containers/containercontrol.md)
      * [UserControl](/api/wisej.web/containers/wisej.web.usercontrol.md)

Provides an empty control that can be used to create other controls.

{% tabs %}
{% tab title="C#" %}

```csharp
public class UserControl : ContainerControl
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class UserControl
    Inherits ContainerControl
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/hsR4ok3152WyAf8J2C1u) UserControl()

Initializes a new instance of the [UserControl](/api/wisej.web/containers/wisej.web.usercontrol.md) class.

### ![](/files/hsR4ok3152WyAf8J2C1u) UserControl(controls)

Initializes a new instance of the [UserControl](/api/wisej.web/containers/wisej.web.usercontrol.md) class with the specified settings.

| Name         | Type                                             | Description                                                                                |
| ------------ | ------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| **controls** | [Control\[\]](/api/wisej.web/general/control.md) | An array of [Control](/api/wisej.web/general/control.md) objects to be added to the panel. |

### ![](/files/hsR4ok3152WyAf8J2C1u) UserControl(location, size, controls)

Initializes a new instance of the [UserControl](/api/wisej.web/containers/wisej.web.usercontrol.md) class with the specified settings.

| Name         | Type                                                                | Description                                                                                |
| ------------ | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| **location** | [Point](https://docs.microsoft.com/dotnet/api/system.drawing.point) | The location of the panel on its parent control.                                           |
| **size**     | [Size](https://docs.microsoft.com/dotnet/api/system.drawing.size)   | The size of the panel.                                                                     |
| **controls** | [Control\[\]](/api/wisej.web/general/control.md)                    | An array of [Control](/api/wisej.web/general/control.md) objects to be added to the panel. |

## Properties

### ![](/files/hsR4ok3152WyAf8J2C1u) AutoSize

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether the control should automatically resize based on its contents. (Default: `False`)

### ![](/files/hsR4ok3152WyAf8J2C1u) AutoSizeMode

[AutoSizeMode](/api/wisej.web/enumerations/wisej.web.autosizemode.md): Returns or sets how the control will resize itself. (Default: `GrowOnly`)

### ![](/files/hsR4ok3152WyAf8J2C1u) AutoValidate

[AutoValidate](/api/wisej.web/enumerations/wisej.web.autovalidate.md): Returns or sets how the control performs validation when the user changes focus to another control.

### ![](/files/hsR4ok3152WyAf8J2C1u) BorderStyle

[BorderStyle](/api/wisej.web/enumerations/wisej.web.borderstyle.md): Returns or sets the border style of the user control. (Default: `None`)

### ![](/files/lzopMboA31bVq8UIcbT3) DefaultSize

[Size](https://docs.microsoft.com/dotnet/api/system.drawing.size):

### ![](/files/hsR4ok3152WyAf8J2C1u) DisplayRectangle

[Rectangle](https://docs.microsoft.com/dotnet/api/system.drawing.rectangle): Returns the rectangle that represents the virtual display area of the control.

## Methods

### ![](/files/hsR4ok3152WyAf8J2C1u) FocusActiveControl()

Selects the active control. If the active control is not focusable, it selects the next focusable control.

### ![](/files/lzopMboA31bVq8UIcbT3) OnCreateControl()

Raised by the [CreateControl](/api/wisej.web/general/control.md#createcontrol) method when the control is created.

### ![](/files/lzopMboA31bVq8UIcbT3) OnLoad(e)

Fires the [Load](#load) event.

| Parameter | Type                                                                | Description                                                                                         |
| --------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| **e**     | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | A [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnWebRender(config)

Renders the client component.

| Parameter  | Type                                                          | Description                   |
| ---------- | ------------------------------------------------------------- | ----------------------------- |
| **config** | [Object](https://docs.microsoft.com/dotnet/api/system.object) | Dynamic configuration object. |

### ![](/files/hsR4ok3152WyAf8J2C1u) ValidateChildren()

Validates all selectable child controls in the container, including descendants. This is equivalent to calling ValidateChildren(ValidationConstraints.Selectable). See [Selectable](/api/wisej.web/enumerations/wisej.web.validationconstraints.md#fields) for details of exactly which child controls will be validated.

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). true if all of the children validated successfully; otherwise, false. If called from the [Validating](/api/wisej.web/general/control.md#validating) or [Validated](/api/wisej.web/general/control.md#validated) event handlers, this method will always return false.

### ![](/files/hsR4ok3152WyAf8J2C1u) ValidateChildren(flags)

Validates all the child controls in the container. Exactly which controls are validated and which controls are skipped is determined by *flags* .

| Parameter | Type                                                                                    | Description                                                                                                               |
| --------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| **flags** | [ValidationConstraints](/api/wisej.web/enumerations/wisej.web.validationconstraints.md) | Places restrictions on which controls have their [Validating](/api/wisej.web/general/control.md#validating) event raised. |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). true if all of the children validated successfully; otherwise, false. If called from the [Validating](/api/wisej.web/general/control.md#validating) or [Validated](/api/wisej.web/general/control.md#validated) event handlers, this method will always return false.

## Events

### ![](/files/hsR4ok3152WyAf8J2C1u) AutoSizeChanged

[EventHandler](https://docs.microsoft.com/dotnet/api/system.eventhandler) Fired when the [AutoSize](#autosize) property changes.

### ![](/files/hsR4ok3152WyAf8J2C1u) AutoValidateChanged

[EventHandler](https://docs.microsoft.com/dotnet/api/system.eventhandler) Fired when the [AutoValidate](#autovalidate) property changes.

### ![](/files/hsR4ok3152WyAf8J2C1u) Load

[EventHandler](https://docs.microsoft.com/dotnet/api/system.eventhandler) Occurs before the control becomes visible for the first time.

## Inherited By

| Name                                                          | Description                                                         |
| ------------------------------------------------------------- | ------------------------------------------------------------------- |
| [UserPopup](/api/wisej.web/containers/wisej.web.userpopup.md) | Provides an popup container that can be attached to other controls. |

## Implements

| Name                                                                              | Description                                                                                                           |
| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| [IUserData](/api/wisej.web/interfaces/wisej.web.iuserdata.md)                     | Provides access to the `UserData` and `Tag` properties associated to the component implementing this interface.       |
| [IBindableComponent](/api/wisej.web/data-binding/wisej.web.ibindablecomponent.md) | Bindable components implement this interface.                                                                         |
| [IContainerControl](/api/wisej.web/interfaces/wisej.web.icontainercontrol.md)     | Provides the functionality for a control to act as a parent for other controls.                                       |
| [IDropTarget](/api/wisej.web/interfaces/wisej.web.idroptarget.md)                 | Controls that support drag & drop operations implement this interface.                                                |
| [IWisejComponent](/api/wisej.core/interfaces/wisej.core.iwisejcomponent.md)       | All wisej components implement this interface.                                                                        |
| [IWisejControl](/api/wisej.core/interfaces/wisej.core.iwisejcontrol.md)           | All wisej controls derived from the [Control](/api/wisej.web/general/control.md) class must implement this interface. |
| [IWisejSerializable](/api/wisej.core/interfaces/wisej.core.iwisejserializable.md) | Allows an object to serialize itself.                                                                                 |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/wisej.web/containers/wisej.web.usercontrol.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
