Hello,
I finally figured out how to prevent a user from re-ordering the first column in my grid.
Here's how I did it:
In the DataLoaded event of my grid I typed in this line (for the first column in grid):
((Telerik.Windows.Controls.GridView.GridViewDataControl)(sender)).Columns[0].IsReorderable = false;
What's kind of strange about this command is that I can't reorder the first column but I can move other columns in front of it. Here's what I did to prevent this problem:
In the ColumnReordered event of the grid I typed in the following lines of code:
private void ColumnReordered(object sender, GridViewColumnEventArgs e)
{
if (e.Column.DisplayIndex == 0)
for (int i = 1; i < gridname.Columns.Count ; i++)
if (e.Column.Header == gridname.Columns[i].Header)
e.Column.DisplayIndex = i;
}
Note. e.Column.DisplayIndex indicates where the user tried to move the column to.
If the user attempts to move a column to the position of the first column, the code above will search for the original location of the column being moved and set e.Column.DisplayIndex back to it's original value. Essentially I am moving the column back to its original location.