how to set the datagridview columns to allow user to click to sort

  • Thread starter Thread starter AboutJAV
  • Start date Start date
A

AboutJAV

Hi,

I have a datagridview with 3 columns. the grid selectionmode is set
to

this.grid.SelectionMode =
System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;


I even set the columns sort property to

System.Windows.Forms.DataGridViewColumnSortMode.Automatic


When the form is loaded and any of the 3 columns are clicked, nothing
happens. The data does not reordered in any directions.

Any advice is appreciated.

Thanks,
 
The datagridview is bounded to an object with a collection.

You'll have to be more specific about the collection that you're using..
eg: by default a BindingList<T> does not support sorting.

A websearch will return you many valueable resources with
implementations of collections that do allow sorting. Even i was
able to write a SortableBindingList<T>
(http://www.timvw.be/presenting-the-sortablebindinglistt/)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top