Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • One of the columns in my DevExpress xtragrid is not sorting, grouping or filtering. Answers to similar questions suggest I need to implement IComparable, but when I did that it no longer displays in the column at all.

                                    	
                                    [C#]
                                    public class Flow : System.IComparable<Flow>, System.IComparable { public Flow(int id, string name, string description) { this.ID = id; this.Name = name; this.Description = description; } public int ID { get; private set; } public string Name { get; private set; } public string Description { get; private set; } public override string ToString() { return Name; } public override bool Equals(object obj) { Flow flow = obj as Flow; if (flow == null) return false; return this.ID == flow.ID; } public static bool operator ==(Flow flow1, Flow flow2) { if (object.ReferenceEquals(null, flow1)) return object.ReferenceEquals(null, flow2); return flow1.Equals(flow2); } public static bool operator !=(Flow flow1, Flow flow2) { return !(flow1 == flow2); } public override int GetHashCode() { return ID; } public int CompareTo(Flow other) { return this.Name.CompareTo(other.Name); } public int CompareTo(object obj) { if (object.ReferenceEquals(null, obj)) return 1; Flow flow = obj as Flow; if (flow == null) return 1; return this.Name.CompareTo(flow.Name); } }

                                    What have I done wrong?

                                You must  log in  or  register  to leave comments

                                1 Solution

                                1

                                The disappearing content was an unrelated issue - a red herring. The column allowed sorting once I had implemented IComparable rather than IComparable<Flow>

                                	
                                [C#]
                                public int CompareTo(object obj) { if (object.ReferenceEquals(null, obj)) return 1; Flow flow = obj as Flow; if (flow == null) throw new ArgumentException("Object is not of type Flow"); return this.Name.CompareTo(flow.Name); }
                                Sourced from MSDN documentation for IComparable.CompareTo Method

                                You must  log in  or  register  to leave comments

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners