We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Including ''arrows'' in header of manually sorted list

Hi, I am binding the databound grid control to an arraylist of my custom objects, manually adding GridBoundColumns for the columns that I wish to display. The grid didn''t automatically provide sorting (I''m guessing because I didn''t implement iComparable??). I''ve manually wired it up so that when they click on a column heading, a customised comparer object bound to the arraylist reorders the data. I then rebind the AL to the grid and ''voila''. This works fine. The problem is that I can''t get the little arrows showing up and down in the currently sorted by column headings. Can you please show me how to set these manually? Thanks in advance, Damien

2 Replies

AD Administrator Syncfusion Team April 2, 2004 06:33 AM UTC

In order for the GridDataBoundGrid to handle sorting, the datasource must implement IBindingList and supporting through its sorting implementation methods. ArrayList does not implement IBindingList. To get the sort headers I think the simplest thing to do is to add a member to your class, sortedCol, that you set when you sort a column. Then handled the PrepareViewStyleInfo event, and if the cell is your sort header cell, set its properties there. //add the member private int sortedCol //then after you complete your sort, insert code to set the //member and redraw the header row so PrepareViewStyleInfo will be hit this.sortedCol = e.ColIndex; this.gridDataBoundGrid1.RefreshRange(GridRangeInfo.Row(0)); //the event handler private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e) { if(e.RowIndex == 0 && e.ColIndex == sortedCol) { e.Style.CellType = "ColumnHeaderCell"; e.Style.Tag = ListSortDirection.Descending; } }

DS Damien Sawyer April 2, 2004 12:06 PM UTC

Thanks Clay, Perfect.

Live Chat Icon For mobile
Up arrow icon