Hi,

Im using a datagridview with a object as its datasource..

Im willing to provide sorting functionality for the same but as the datasource is object it is not allowing me to sort the columns in the gridview.

is ther any way to achieve the same?

i have visited the MSDN link which describes the way to use Ibinding source for the same.
but im not getting the exact solution for the same..

can anyone please help me out for the same?

Have your object override IComparable... the object will then be sortable.

For example, the following will cause the objects to be sorted by it's Name member variable:

public class foo : IComparable
		{
			public string Name { get; set; }
			public double Something { get; set; }
			public double SomethingElse { get; set; }

			#region IComparable Members

			public int CompareTo(object obj)
			{
				return Name.CompareTo((obj as foo).Name);
			}

			#endregion
		}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.