Home - Forums-.NET - FlyGrid.Net (Windows Forms) - AllowSorting=false?

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

AllowSorting=false?
Link Posted: 15-Aug-2005 00:14
Dear Support-Team,

i'am working with your powerfull flygrid, but i have one little problem. How can i disallow sorting for one or more columns?

I think it must be simple, but i can't find it.

THX
Formisano
Link Posted: 15-Aug-2005 02:41
To disable sorting on some column (columns) simply set AllowSorting
property to false of this(these) columns.
Link Posted: 15-Aug-2005 03:21
[quote="Anonymous"]To disable sorting on some column (columns) simply set AllowSorting
property to false of this(these) columns.


This is the normal way to go, but the flygrid hasn't such property when i type "myflygrid.Columns.*" or "myflygrid.Column[0].*".
Link Posted: 15-Aug-2005 04:06
Here is example code showing how to disable or enable sorting on columns:

[C#]
private void SetAllowSorting(FlyGrid flyGrid, bool allow, bool onlyToVisibleColumns)
{
if (onlyToVisibleColumns)
{
    foreach(Column col in flyGrid.Columns.VisibleColumns)
    {
       col.AllowSorting = allow;
    }
}
else
{
     foreach(Column col in flyGrid.Columns.Items)
    {
       col.AllowSorting = allow;
    }
}
}


or you can set AllowSorting to some column by index:


[C#]
private void SetAllowSorting(FlyGrid flyGrid, int index, bool allow)
{
   flyGrid.Columns.Items[index].AllowSorting = allow;
}


To disable sorting on all columns you can use followin code:

[C#]
flyGrid.Columns.Options &= ~(ColumnsOptions.ChangeSortOrderOnClick | ColumnsOptions.ShowSortOrderMark);
Link Posted: 15-Aug-2005 07:29
Thank you! That's it!