Fixed columns are always visible and are not engaged in horizontal sorting. To freeze a column, use Header.FixedColumns.Count to set the desired number of constantly displayed unscrollable columns.
C# | Copy |
---|---|
public void FixedColumnsExample(Grid grid) { //Add a new header on the top hierarchical level (level 0) Header header = new Header(); header.Add(new Column("Column1")); header.Add(new Column("Column2")); header.Add(new Column("Column3")); grid.Headers.Add(header); Console.WriteLine("Fixed columns count: {0}", header.FixedColumns.Count); //Set the number of non-scrollable columns header.FixedColumns.Count = 2; foreach (Column column in header.FixedColumns) { Console.WriteLine("Fixed column: id = '{0}'", column.Id); } //All columns in the grid will be scrollable header.FixedColumns.Clear(); Console.WriteLine("Fixed columns count: {0}", header.FixedColumns.Count); Console.WriteLine("Columns count: {0}", header.Count); } //Output: //Fixed columns count: 0 //Fixed column: id = 'Column1' //Fixed column: id = 'Column2' //Fixed columns count: 0 //Columns count: 3 |
Back to .Net Grid HowTo topics