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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:





12569 Apr 2,2004 02:09 AM UTC Apr 2,2004 12:06 PM UTC WinForms 2
Tags: GridControl
Damien Sawyer
Asked On April 2, 2004 02:09 AM UTC

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

Administrator [Syncfusion]
Replied On 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; } }

Damien Sawyer
Replied On April 2, 2004 12:06 PM UTC

Thanks Clay, Perfect.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon