Home Forums WinForms controls Xceed Grid for WinForms Can I freeze Columns in v2? Reply To: Can I freeze Columns in v2?

User (Old forums)
Member
Post count: 23064

I don’t think you can, without using code. But here’s a class you can use to freeze the first column:<code>public class ColumnFreezer
{
private Xceed.Grid.Column column_;
public ColumnFreezer(Xceed.Grid.Column column)
{
column_ = column;
Xceed.Grid.GridControl grid = column.GridControl;
if (grid != null) grid.FirstVisibleColumnChanged += new EventHandler(grid_FirstVisibleColumnChanged);
}

private void grid_FirstVisibleColumnChanged(object sender, EventArgs e)
{
Xceed.Grid.Column firstColumn = grid.FirstVisibleColumn;
if (firstColumn != null && firstColumn != column_)
column_.VisibleIndex = firstColumn.VisibleIndex;
}
}</code>
To use it:<code>// after initializing the grid
new ColumnFreezer(myGrid.Columns[“myColumn”]);</code>

Imported from legacy forums. Posted by Tommy (had 267 views)