# Basic Operations

## Content



This topic discusses various basic operations which can be performed on a column.

## Add Column

FlexGrid lets you add new columns using the **Columns** property of **FlexGrid** class, which gets the collection of columns of the grid. For this purpose, the **C1DataCollectionList\<T>** class provides the **Add(T item)** method. This class is a member of C1.DataCollection namespace of C1.DataCollection assembly, and it works like a Data collection wrapper. Also, note that if a new column is added to a bound grid using this method, it is added as an unbound column only.

Following is the code snippet to add column to the FlexGrid control.

```csharp
// Add Unbound column in bound grid - check column is added at the end of grid
flexGrid1.Columns.Add(new GridColumn { Header = "New Unbound Col", Width = new GridLength(1, GridUnitType.Star), MinWidth = 150, AllowMerging = false, HeaderHorizontalAlignment = HorizontalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center });
```

## Delete Column

To delete a particular column from the grid, you can use the **Columns** property of FlexGrid class and **RemoveAt (int index)** method of the **C1DataCollectionList\<T>** class. This method removes the list item at the specified index.

Following is the code snippet to delete column from the FlexGrid.

```csharp
// Delete Column - "FirstName"
flexGrid1.Columns.RemoveAt(1);
```

## Insert Column

To insert a column in FlexGrid at a specific location, you can use the **Columns** property of **FlexGrid** class and **Insert** **(int index, T item)** method of the **C1DataCollectionList\<T>** class, which inserts an item at the specified index.

Following is the code snippet to insert a column in the FlexGrid column at the specified location.

```csharp
// Insert column at 0th position and bind it with property "FirstName"
flexGrid1.Columns.Insert(0, new GridColumn { Header = "BoundCol-FName", Width = new GridLength(1, GridUnitType.Star), MinWidth = 120, AllowMerging = false, HeaderHorizontalAlignment = HorizontalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, Binding = "FirstName" });
```

## Set Frozen Column

Frozen columns, similar to fixed columns, are non-scrollable but can be edited by the user. In FlexGrid, frozen columns can be set by using [FrozenColumns](/componentone/api/winui/online-winui/dotnet-api/C1.WinUI.Grid/C1.WinUI.Grid.FlexGrid.FrozenColumns.html) and [FrozenRows](/componentone/api/winui/online-winui/dotnet-api/C1.WinUI.Grid/C1.WinUI.Grid.FlexGrid.FrozenRows.html) property provided by the [FlexGrid](/componentone/api/winui/online-winui/dotnet-api/C1.WinUI.Grid/C1.WinUI.Grid.FlexGrid.html) class.

To set frozen columns in the FlexGrid control, use the code below.

**csharp**

```csharp
// Set Frozen Column - it is set in XAML code also
flexGrid1.FrozenColumns = 1;
flexGrid1.FrozenRows = 2;
```

**xml**

```xml
<c1:FlexGrid x:Name="flexGrid1" FrozenColumns="1" FrozenRows="2" AllowMerging="Cells" AutoGenerateColumns="False">
</c1:FlexGrid>
```