# Pinned Rows and Columns

VirtualGrid provides a pinning mechanism for both its rows and columns. Through it, a given row can be pinned to the top or bottom of the grid. Respectively, a column can be pinned to the left or right side of VirtualGrid. Thus, they will not take part in the vertical or horizontal scrolling.

## Pin Rows and Columns

The pin functionality can be controlled using the following methods exposed by the API of the control.

* `PinRowTop(int index)`—Pins a row at a given index on the top.

  **Example 1: Calling the PinRowTop method**

  ```C#
  virtualGrid.PinRowTop(1);
  ```

> caption RadVirtualGrid with pinned row at the top

```
![RadVirtualGrid with pinned row on the top](images/RadVirtualGrid_Features_PinnedRowsColumns_01.png)
```

* `PinRowBotton(int index)`—Pins a row at a given index to the bottom.

  **Example 2: Calling the PinRowBottom method**

  ```C#
  virtualGrid.PinRowBottom(1);
  ```

> caption RadVirtualGrid with pinned row at the bottom

```
![RadVirtualGrid with pinned row at the bottom](images/RadVirtualGrid_Features_PinnedRowsColumns_02.png)
```

* `PinColumnLeft(int index)`—Pins a column at a given index to the left.

  **Example 3: Calling the PinColumnLeft method**

  ```C#
  virtualGrid.PinColumnLeft(1);
  ```

> caption RadVirtualGrid with pinned column on the left

```
![ RadVirtualGrid with pinned column on the left](images/RadVirtualGrid_Features_PinnedRowsColumns_03.png)
```

* `PinColumnRight(int index)`—Pins a column at a given index to the right.

  **Example 4: Calling the PinColumnRight method**

  ```C#
  virtualGrid.PinColumnRight(1);
  ```

> caption RadVirtualGrid with pinned column on the right

```
![RadVirtualGrid with pinned column on the right](images/RadVirtualGrid_Features_PinnedRowsColumns_04.png)
```

## Unpin Rows and Columns

Unpinning an already pinned row or column can be achieved through the `UnpinRow` and `UnpinColumn` methods.

* `UnpinRow(int index)`—Unpins a row at a given index.

* `UnpinColumn(int index)`—Unpins a column at a given index.

**Example 5: Unpin methods usage**

```C#
virtualGrid.UnpinRow(1);
virtualGrid.UnpinColumn(1);
```

## Commands Support

VirtualGrid exposes built-in commands for its pinning functionality. They can be accessed via the `RadVirtualGridCommands` and executed using the `PendingCommands` collection property of the VirtualGrid and its `ExecutePendingCommand` method.

The available commands are `PinRowTop`, `PinRowBottom`, `PinColumnLeft`, `PinColumnRight`, `UnpinRow` and `UnpinColumn`. Read more about the commanding support in the [Commands Overview](https://www.telerik.com/products/wpf/documentation/controls/radvirtualgrid/commands/overview) article.

## Usage with Filtering and Sorting

The pinned rows feature is not supported when filtering or sorting is applied. In case you already have pinned rows and then apply filtering or sorting, the rows will get unpinned. After, the filtering and sorting is cleared, the previously pinned rows will be restored.

## See also

* [Editing](https://www.telerik.com/products/wpf/documentation/controls/radvirtualgrid/features/editing)
* [Insert and Remove Data](https://www.telerik.com/products/wpf/documentation/controls/radvirtualgrid/features/insert-and-remove-data)
