Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid Sort 1

Status
Not open for further replies.

bueller

Programmer
Aug 27, 2002
76
US
Hi all,

I am having a tough time with the ever enjoyable datagrid. I have been looking all around for a way to just tell the grid to sort on a field, like how it sorts when you click on a field, but have only found stuff for sorting the data before you bind it to the grid. I am looking to see if anyone has any samples or can point me to a way of how to force the grid to resort itself.
Thanks,
Bueller
 
Thanks for the examples, but i was looking for stuff for a datagrid on a form in VB .NET. There is no onsort function for the datagrid in VB .NET. I need to know how to sort it on a form so when the form loads up i can tell it to sort by the particular field.
Thanks,
Bueller
 
This is what I found in help in Studio.Net.

"Use the OnSortCommand method to provide a custom handler for the SortCommand event.

The SortCommand event is raised when a column is sorted.

A typical handler for the SortCommand event sorts the list, and then rebinds the data to the DataGrid control.

Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

Notes to Inheritors: When overriding OnSortCommand in a derived class, be sure to call the base class's OnSortCommand method."

It also provided an example for a web page but same logic applies to winform.

 
Hi All,

I still am having an issue with this but actually looked harder at the project and found out that the datagrid is being bound to a custom inherited datatable. The table is the datasource for the grid so i cannot change the datasource of the grid. So is there a way to simulate a mouseclick on the grid row that i want to sort or do i need to rewrite it so that i can have the datasource of the grid to be a dataview so i can always sort it properly.
Thanks,
bueller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top