# UserControl

Namespace: **Wisej.Web**

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

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

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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) UserControl()

Initializes a new instance of the [UserControl](https://docs.wisej.com/api/wisej.web/containers/wisej.web.usercontrol) class.

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) UserControl(controls)

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

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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) UserControl(location, size, controls)

Initializes a new instance of the [UserControl](https://docs.wisej.com/api/wisej.web/containers/wisej.web.usercontrol) 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\[\]](https://docs.wisej.com/api/wisej.web/general/control) | An array of [Control](https://docs.wisej.com/api/wisej.web/general/control) objects to be added to the panel. |

## Properties

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) 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`)

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) AutoSizeMode

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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) AutoValidate

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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) BorderStyle

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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-9bf7fa01e02f4da0f9ef90d3b049ae43e664919e%2Fprotected.png?alt=media) DefaultSize

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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) DisplayRectangle

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

## Methods

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) FocusActiveControl()

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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-9bf7fa01e02f4da0f9ef90d3b049ae43e664919e%2Fprotected.png?alt=media) OnCreateControl()

Raised by the [CreateControl](https://docs.wisej.com/api/general/control#createcontrol) method when the control is created.

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-9bf7fa01e02f4da0f9ef90d3b049ae43e664919e%2Fprotected.png?alt=media) 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. |

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-9bf7fa01e02f4da0f9ef90d3b049ae43e664919e%2Fprotected.png?alt=media) OnWebRender(config)

Renders the client component.

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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) ValidateChildren()

Validates all selectable child controls in the container, including descendants. This is equivalent to calling ValidateChildren(ValidationConstraints.Selectable). See [Selectable](https://docs.wisej.com/api/enumerations/wisej.web.validationconstraints#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](https://docs.wisej.com/api/general/control#validating) or [Validated](https://docs.wisej.com/api/general/control#validated) event handlers, this method will always return false.

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) 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](https://docs.wisej.com/api/wisej.web/enumerations/wisej.web.validationconstraints) | Places restrictions on which controls have their [Validating](https://docs.wisej.com/api/general/control#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](https://docs.wisej.com/api/general/control#validating) or [Validated](https://docs.wisej.com/api/general/control#validated) event handlers, this method will always return false.

## Events

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) AutoSizeChanged

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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) AutoValidateChanged

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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) 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](https://docs.wisej.com/api/wisej.web/containers/wisej.web.userpopup) | Provides an popup container that can be attached to other controls. |

## Implements

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