How to enable user to click anywhere on header to sort by that column?

Posted by: frankchen on 8 September 2017, 2:44 pm EST

  • Posted 8 September 2017, 2:44 pm EST

    My programs is:

    public Form1()
                var table = new DataTable();
                var row = table.NewRow();
                row[0] = 1;
                row[1] = "T";

                row = table.NewRow();
                row[0] = 3;
                row[1] = "S";

                fpSpread1_Sheet1.DataSource = table;
                foreach (Column col in fpSpread1_Sheet1.Columns)
                    col.AllowAutoSort = true;
                    col.ShowSortIndicator = true;
                    col.TextIndent = 0;
                    col.HorizontalAlignment = CellHorizontalAlignment.Left;

    but currently, it only works if user clicks on small blank area to the right of the column herader, that is only clicking on the sort indicator can sort that column.

    how to eable user to click anywhere of the column header to sort?



  • Replied 8 September 2017, 2:44 pm EST

    Hello Frank,

    You can sort the rows using the SortRows method, to enable the user to sort the column as soon as the user clicks any where in the column header.  I have created a sample in which, when the user clicks on the column header, the column gets sorted in ascending order, kindly have a look at the sample.

    Please let me know if you have any queries further.


    Manpreet Kaur.

  • Replied 8 September 2017, 2:44 pm EST

    Thank you! I will have a try and let you know the result.

  • Replied 8 September 2017, 2:44 pm EST

    It works!

    Thank you!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels