Prop Webcontrol Listbox Rows
## ASP.NET Web Control: ListBox Rows Property
The `Rows` property is a key attribute of the ASP.NET `ListBox` web control. It allows developers to define the number of items that are visible at one time within the list box without the user needing to scroll.
---
## Definition and Usage
The `Rows` property gets or sets the number of visible rows in a `ListBox` control.
* **Default Behavior:** If this property is not set, the browser determines the default height of the list box (typically displaying 4 rows by default in most browsers).
* **Scrollbars:** If the `ListBox` contains more items than the number specified in the `Rows` property, a vertical scrollbar will automatically appear to allow users to scroll through the remaining items.
---
## Syntax
```xml
```
### Property Values
| Attribute Value | Description |
| :--- | :--- |
| `num` | An integer that specifies the number of visible rows in the `ListBox` control. The value must be greater than or equal to `1`. |
---
## Code Example
The following example demonstrates how to set the `Rows` property of a `ListBox` control to display exactly 5 items at once.
```xml
```
### How it behaves:
* The `ListBox` will render with a height sufficient to display exactly 5 items (`Item 1` through `Item 5`).
* Because there are 7 items in total, a vertical scrollbar will automatically be rendered so the user can scroll down to select `Item 6` and `Item 7`.
---
## Technical Considerations
1. **Rendering in HTML:** When compiled and sent to the client browser, the ASP.NET `` control renders as an HTML `
YouTip