# Form

A `Form` is a representation of any window displayed in your application. The `Form` class can be used to create standard, tool, borderless, and floating windows. You can also use the `Form` class to create modal windows such as a dialog box. A special kind of form, the multiple-document interface (MDI) form, can contain other forms called MDI child forms. An MDI form is created by setting the `IsMdiContainer` property to `true`. MDI child forms are created by setting the `MdiParent` property to the MDI parent form that will contain the child form.

Using the properties available in the `Form` class, you can determine the appearance, size, color, and window management features of the window or dialog box you are creating. The `Text` property allows you to specify the caption of the window in the title bar. The `Size` and `Location` properties allow you to define the size and position of the window when it is displayed. You can use the `ForeColor` property to change the default foreground color of all controls placed on the form. The `FormBorderStyle`, `MinimizeBox`, and `MaximizeBox` properties allow you to control whether the form can be minimized, maximized, or resized at run time.

![Form designer showing pixel-perfect layout capabilities](https://553579532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF1D11gPs_az3xaKusw%2Fuploads%2Fgit-blob-719db308e8705aeb2507b92d6a1f3961842cca05%2Fimage.png?alt=media)

{% hint style="info" %}
For a full list of properties, methods and events see the [API documentation.](http://docs.wisej.com/api)
{% endhint %}

## Features

### Container

Similar to WinForms, the `Form` control acts as a container for any other Wisej.NET control and can be manipulated in the designer to fit its contents.

![Form demonstrating container capabilities with multiple child controls](https://553579532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF1D11gPs_az3xaKusw%2Fuploads%2Fgit-blob-8fec99ea227494d22bc43f59ae6d8552b31dfa62%2Fimage.png?alt=media)

### Modal Dialog

Modal Dialogs are used to demand an action from a user. They draw the user's attention away from other parts of the form and require the user to attend to an action.

A `Form` control can be shown as a modal dialog by calling the `ShowDialog()` method.

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

```csharp
// create and show a modal form.
var form = new MyForm();
var result = form.ShowDialog();
if (result == DialogResult.OK)
    AlertBox.Show("Success");
    
// or

// create and dispose of a form upon completion.
using (var form = new MyForm())
    if (form.ShowDialog() == DialogResult.OK)
        AlertBox.Show("Success");
```

{% endtab %}
{% endtabs %}

{% hint style="danger" %}
Modal dialogs are not disposed when closed. **They are reusable.** If you don't intend to reuse a modal dialog call `Dispose()` when closed or use the [using](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement) pattern.
{% endhint %}

### Modal Form

The `Form` can also be shown in a manner that simulates a modal-appearance without the modal functionality.

Simply set the `ModalMask` property to `true` and call the Form's `Show()` method.

An optional callback can be specified upon completion:

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

```csharp
var form = new MyForm
{
    ShowModalMask = true
};
form.Show((form, result) => AlertBox.Show(result.ToString()));
```

{% endtab %}
{% endtabs %}

## Advanced

### JavaScript Widget

| Item                | Description                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Class name          | "wisej.web.Form"                                                                                                                                                                                                                                                                                                                                                                                 |
| Theme appearance    | "window", see [Themes](https://docs.wisej.com/theme-builder/theme-elements/elements).                                                                                                                                                                                                                                                                                                            |
| Child components    | "captionbar", "title" is the title of the window, "icon" is the icon in the left top corner of the window, "minimize-button" is minimize button, "close-button" is the close button, "maximize-button" is the maximize button, "restore-button" is the restore button, "pane" is the content part of the window. See [JavaScript](https://docs.wisej.com/docs/concepts/javascript-object-model). |
| Toolcontainer state | "caption", see [Embedded Tools](https://docs.wisej.com/docs/controls/general/embedded-tools).                                                                                                                                                                                                                                                                                                    |
| Source code         | [https://github.com/iceteagroup/wisej-js](https://github.com/iceteagroup/wisej-js/blob/master/wisej.web.TextBox.js)                                                                                                                                                                                                                                                                              |
