# ListBoxExtensions

Namespace: **Wisej.Web.Markup**

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

Adds [fluent markup](https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/markup/markup) extension methods to the [ListBox](/api/wisej.web/lists-and-grids/listbox.md) class.

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

```csharp
public class ListBoxExtensions
```

{% endtab %}

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

```visual-basic
Public Class ListBoxExtensions
```

{% endtab %}
{% endtabs %}

## Methods

### ![](/files/lIX317sDtMTZJBi9oSIx) HorizontalScrollbar\<TListBox>(listBox, value)

Sets the HorizontalScrollbar property of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter    | Type                                                                               | Description                                                                                       |
| ------------ | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox** |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**  | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box for which to set the HorizontalScrollbar property.                                   |
| **value**    | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                    | A boolean indicating whether a horizontal scrollbar is shown.                                     |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the updated HorizontalScrollbar property.

This method allows you to specify whether a horizontal scrollbar should be shown for the list box.

```csharp

myListBox.HorizontalScrollbar(true);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) IncrementalSelection\<TListBox>(listBox, value)

Sets the IncrementalSelection property of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter    | Type                                                                               | Description                                                                                       |
| ------------ | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox** |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**  | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box for which to set the IncrementalSelection property.                                  |
| **value**    | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                    | A boolean indicating whether incremental selection is enabled.                                    |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the updated IncrementalSelection property.

This method allows you to enable or disable incremental selection for the list box.

```csharp

myListBox.IncrementalSelection(true);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) ItemHeight\<TListBox>(listBox, itemHeight)

Sets the ItemHeight property of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter      | Type                                                                               | Description                                                                                       |
| -------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox**   |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**    | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box for which to set the ItemHeight property.                                            |
| **itemHeight** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32)                        | The height of each item in the list box.                                                          |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the updated ItemHeight property.

This method allows you to specify the height of each item in the list box.

```csharp

myListBox.ItemHeight(20);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) Items\<TListBox>(listBox, items)

Adds the specified items to the Items collection of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter    | Type                                                                               | Description                                                                                       |
| ------------ | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox** |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**  | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box to which the items should be added.                                                  |
| **items**    | [Object\[\]](https://docs.microsoft.com/dotnet/api/system.object)                  | An array of items to add to the list box.                                                         |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the added items.

This method allows you to add multiple items to the list box in one call.

```csharp

myListBox.Items("Item1", "Item2", "Item3");

```

### ![](/files/lIX317sDtMTZJBi9oSIx) LazyLoading\<TListBox>(listBox, value)

Sets the LazyLoading property of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter    | Type                                                                               | Description                                                                                       |
| ------------ | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox** |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**  | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box for which to set the LazyLoading property.                                           |
| **value**    | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                    | A boolean indicating whether lazy loading is enabled.                                             |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the updated LazyLoading property.

This method allows you to enable or disable lazy loading for the list box.

```csharp

myListBox.LazyLoading(true);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnSelectedIndexChanged\<TListBox>(listBox, action)

Attaches an event handler for the SelectedIndexChanged event of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter    | Type                                                                               | Description                                                                                       |
| ------------ | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox** |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**  | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box to attach the event handler to.                                                      |
| **action**   | [Action\<TListBox>](https://docs.microsoft.com/dotnet/api/system.action-1)         | An action to execute when the SelectedIndex property changes.                                     |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the attached SelectedIndexChanged event handler.

This method allows you to execute a custom action whenever the SelectedIndex property of the list box changes.

```csharp

myListBox.OnSelectedIndexChanged(lb =>
{
AlertBox.Show("Selected index changed!");
});

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnSortedChanged\<TListBox>(listBox, action)

Attaches an event handler for the SortedChanged event of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter    | Type                                                                               | Description                                                                                       |
| ------------ | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox** |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**  | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box to attach the event handler to.                                                      |
| **action**   | [Action\<TListBox>](https://docs.microsoft.com/dotnet/api/system.action-1)         | An action to execute when the Sorted property changes.                                            |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the attached SortedChanged event handler.

This method allows you to execute a custom action whenever the Sorted property of the list box changes.

```csharp

myListBox.OnSortedChanged(lb =>
{
AlertBox.Show("Sorted property changed!");
});

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnToolClick\<TListBox>(listBox, action)

Attaches an event handler for the ToolClick event of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter    | Type                                                                                           | Description                                                                                       |
| ------------ | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox** |                                                                                                | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**  | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md)             | The list box to attach the event handler to.                                                      |
| **action**   | [Action\<TListBox, ToolClickEventArgs>](https://docs.microsoft.com/dotnet/api/system.action-2) | An action to execute when a tool in the list box is clicked.                                      |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the attached ToolClick event handler.

This method allows you to execute a custom action whenever a tool in the list box is clicked.

```csharp

myListBox.OnToolClick((lb, args) =>
{
AlertBox.Show("Tool clicked!");
});

```

### ![](/files/lIX317sDtMTZJBi9oSIx) Orientation\<TListBox>(listBox, orientation)

Sets the Orientation property of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter       | Type                                                                               | Description                                                                                       |
| --------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox**    |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**     | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box for which to set the Orientation property.                                           |
| **orientation** | [Orientation](/api/wisej.web/enumerations/wisej.web.orientation.md)                | The [Orientation](#orientation``1) to set for the list box.                                       |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the updated Orientation property.

This method allows you to set the orientation for the list box, which determines how items are displayed.

```csharp

myListBox.Orientation(Orientation.Horizontal);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) RightClickSelection\<TListBox>(listBox, value)

Sets the RightClickSelection property of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter    | Type                                                                               | Description                                                                                       |
| ------------ | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox** |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**  | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box for which to set the RightClickSelection property.                                   |
| **value**    | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                    | A boolean indicating whether right-click selection is enabled.                                    |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the updated RightClickSelection property.

This method allows you to enable or disable right-click selection for the list box.

```csharp

myListBox.RightClickSelection(true);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) ScrollAlwaysVisible\<TListBox>(listBox, value)

Sets the ScrollAlwaysVisible property of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter    | Type                                                                               | Description                                                                                       |
| ------------ | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox** |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**  | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box for which to set the ScrollAlwaysVisible property.                                   |
| **value**    | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                    | A boolean indicating whether the scrollbar is always visible.                                     |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the updated ScrollAlwaysVisible property.

This method allows you to ensure the scrollbar is always visible, regardless of the number of items.

```csharp

myListBox.ScrollAlwaysVisible(true);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) SelectedItem\<TListBox>(listBox, selectedItem)

Sets the SelectedItem property of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter        | Type                                                                               | Description                                                                                       |
| ---------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox**     |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**      | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box for which to set the SelectedItem property.                                          |
| **selectedItem** | [Object](https://docs.microsoft.com/dotnet/api/system.object)                      | The item to select in the list box.                                                               |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the updated SelectedItem property.

This method allows you to specify the selected item in the list box.

```csharp

myListBox.SelectedItem(item);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) SelectionMode\<TListBox>(listBox, selectionMode)

Sets the SelectionMode property of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter         | Type                                                                               | Description                                                                                       |
| ----------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox**      |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**       | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box for which to set the SelectionMode property.                                         |
| **selectionMode** | [SelectionMode](/api/wisej.web/enumerations/wisej.web.selectionmode.md)            | The [SelectionMode](#selectionmode``1) to set for the list box.                                   |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the updated SelectionMode property.

This method allows you to specify the selection mode for the list box.

```csharp

myListBox.SelectionMode(SelectionMode.MultiExtended);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) Sorted\<TListBox>(listBox, value)

Sets the Sorted property of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter    | Type                                                                               | Description                                                                                       |
| ------------ | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox** |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**  | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box for which to set the Sorted property.                                                |
| **value**    | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                    | A boolean indicating whether the list box is sorted.                                              |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the updated Sorted property.

This method allows you to specify whether the items in the list box should be sorted automatically.

```csharp

myListBox.Sorted(true);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) Tools\<TListBox>(listBox, items)

Adds the specified tools to the Tools collection of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter    | Type                                                                               | Description                                                                                       |
| ------------ | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox** |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**  | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box to which the tools should be added.                                                  |
| **items**    | [ComponentTool\[\]](/api/wisej.web/editors/wisej.web.componenttool.md)             | An array of tools to add to the list box.                                                         |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the added tools.

This method allows you to add multiple tools to the list box in one call.

```csharp

myListBox.Tools(tool1, tool2, tool3);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) TopIndex\<TListBox>(listBox, topIndex)

Sets the TopIndex property of the specified [ListBox](/api/wisej.web/lists-and-grids/listbox.md).

| Parameter    | Type                                                                               | Description                                                                                       |
| ------------ | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **TListBox** |                                                                                    | The type of the list box, must inherit from [ListBox](/api/wisej.web/lists-and-grids/listbox.md). |
| **listBox**  | [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md) | The list box for which to set the TopIndex property.                                              |
| **topIndex** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32)                        | The index of the first visible item in the list box.                                              |

**Returns:** [TListBox](/api/wisej.web.markup/extensions/wisej.web.markup.listboxextensions.md). The modified list box with the updated TopIndex property.

This method allows you to specify the index of the first visible item in the list box.

```csharp

myListBox.TopIndex(5);

```


---

# 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.markup/extensions/wisej.web.markup.listboxextensions.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.
