Home Forums WinForms controls Xceed Grid for WinForms Basic Sorting Question

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #14142 |

    This is the most basic of sorting questions, but how do I get the grid to sort when I click on the column header? Do I have to create a class that implement IComparer or something?

    Thats it, nothing fancy, just basic sorting.

    Imported from legacy forums. Posted by jbeerhalter (had 2885 views)

    User (Old forums)
    Member
    Post count: 23064

    Sorting should be automatic. I don’t think you should do anything.

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

    User (Old forums)
    Member
    Post count: 23064

    Hmmm, well then I have somehow turned it off. So lets try to solve this backwards. If I wanted to turn off sorting, how would I go about doing that?

    Imported from legacy forums. Posted by jbeerhalter (had 364 views)

    User (Old forums)
    Member
    Post count: 23064

    Never mind, I found the problem. One of the developers here created a class that inherits from Xceed.Grid.GridControl and put a nice little method on it called AllowSorting(bool). I assumed the code had been tested, but looking at what he’d written, that is obviously not the case. The code is posted below, so you can feel a bit of my insanity when I saw what was written.

    public void AllowSorting(bool value)
    {
    _allowSorting = value;
    int numHead = 0;
    foreach (Xceed.Grid.Row cmRow in FixedHeaderRows)
    {
    ColumnManagerRow cmr = cmRow as ColumnManagerRow;
    if (cmr != null)
    {
    numHead++;
    }
    }

    if (numHead == 0)
    {
    if (_managerRow == null)
    {
    _managerRow = new ColumnManagerRow();
    }
    }

    for (int i=0; i < this.FixedHeaderRows.Count; i++)
    {
    Xceed.Grid.ColumnManagerRow row = this.FixedHeaderRows[i] as Xceed.Grid.ColumnManagerRow;
    if (row != null)
    {
    row.AllowSort = false;
    }
    }
    }

    Imported from legacy forums. Posted by jbeerhalter (had 4073 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.