Column freeze example

Oct 15, 2008 at 8:05 PM

I'm looking for a  simple example on how to freeze columns.

Here is what I'm trying to accomplish. 

1) I select a cell on a datagrid.
2) I find out the column number of the selected cell 



col = DataGrid1.Columns.IndexOf(DataGrid1.CurrentCell.Column)

3) Now I want to freeze this column. I tried to do this


DataGrid1.Columns(col).IsFrozen =


but it dos not work. It gives me the following error:

Error 1 'Set' accessor of property 'IsFrozen' is not accessible. 

What am I doing wrong? A simple example would help.


Oct 15, 2008 at 8:48 PM
IsFrozen is a read-only property so you cannot set a column to be frozen in that manner.  To set frozen columns you have to go with the DataGrid.FrozenColumnCount API.