# Add a UserControl

{% embed url="<https://youtu.be/DaaW7OnlFdM>" %}

You can use the[ UserControl](https://docs.wisej.com/docs/controls/containers/usercontrol) to create a reusable control for your Wisej.NET application. In our case, we want to be able to navigate between pages of an application. On each page, we want the same navigation menu. So it makes sense to use a UserControl because it can be reused on each page.

To create a UserControl:

In the Solution Explorer, right-click and choose Add->New Item

From the menu that pops up, choose "Wisej.NET 4" and then "User Control". (Alternatively choose Wisej.NET 3 if you are using Wisej.NET 3)

<figure><img src="/files/Ezm4yXd0P7AFPNu0tdw4" alt=""><figcaption></figcaption></figure>

Name your UserControl (Ie "Nagivation.cs") and click "Add"

Add some controls from the toolbox- in our case, we added a combobox and a label. Add some items to the combobox- ie "Page1", "Page2", "Page3".

{% hint style="info" %}
Make sure that you have several pages in your application. You can add new pages by right-clicking on the project in the Solution Explorer and choosing Add -> New Item
{% endhint %}

Attach to the SelectedIndexChanged event of the combobox and add the following code to navigate between pages:

```csharp
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
	switch (comboBox1.SelectedItem)
	{
		case "Page1":
			new Page1().Show();
			break;
		case "Page2":
			new Page2().Show();
			break;
		case "Page3":
			new Page3().Show();
			break;
		default:
			new Page1().Show();
			break;
	}
}
```

Compile the project. Open the designer and you will now see the usercontrol. Click and drag it into the page. Repeat this for each page in the application.


---

# 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://www.learnwisej.net/wisej.net-tutorial/next-steps-with-wisej.net/add-a-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.
