set datagridview sort back to nothing

R

Rick

VS 2005/Pro

I'm using a DataGridView in a Windows form and allowing the user to sort the
columns by clicking on the header column.

Is there some method offered by the grid to return back to the unsorted
view?

I think I could "roll my own" by resetting the bindingsource.sort = nothing,
but it seems like the datagridview should have something like this?

Rick
 
C

Cor Ligthert [MVP]

Rick,

I never tried it, but can you use the dataview for the datasource and than
set the sort attribute to its initial which is "".

Please give us the result if this works.

Cor
 
R

Rick

Cor,
I'm not sure you understood.

I can do this now - capture the column header right click and change the
binding source sort to "". See code below.

I wanted to know if the datagridview ALREADY has a built-in method to do
this. For example when you left click on the left header column above the
row marker, you select all the rows in the grid. Is there something that
will unsort the grid that is already in the datagridview component?

Private Sub gridPOItems_ColumnHeaderMouseClick(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
gridPOItems.ColumnHeaderMouseClick
If e.Button = Windows.Forms.MouseButtons.Right Then
If gridPOItems.SortedColumn IsNot Nothing Then
POItemsbind.Sort = ""
End If
End If
End Sub

Rick
 

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

Top