Datagridview sortmode

  • Thread starter Thread starter sid
  • Start date Start date
S

sid

I have a Datagridview being populated from an SQL Table, but one of
the fields is a Date and Time stamp. The 'Automatic' sort still sorts
the field by alpha-numeric, not by date.

How can I force the Datagridview to sort by dates ?
 
You have to base the source data of your datagridview on a dataview
control. The Dataview control has a sort property which you can set in
code - to sort on one or multiple columns.

Dim dv As New Dataview
dv.Table = Dataset1.Tables("tbl1")
dv.Sort = "Col_1 ASC, Col_2 DESC"

There is more information in the Visual Studio 2005 Help files.

Rich
 
You have to base the source data of your datagridview on a dataview
control.  The Dataview control has a sort property which you can set in
code - to sort on one or multiple columns.

Dim dv As New Dataview
dv.Table = Dataset1.Tables("tbl1")
dv.Sort = "Col_1 ASC, Col_2 DESC"

There is more information in the Visual Studio 2005 Help files.

Rich

*** Sent via Developersdexhttp://www.developersdex.com***

Can I do that from the config menu on the side of the datagridview
control ? or do I need to do that from code ?
 
I think you can only do this from code. Do a

Dim dv As Dataview

then place the mouse cursor over Dataview and press F1 to get help on
Dataview. The help files have pretty good documentation and some sample
code. Or just do a google on VB2005 dataview sample code or something
like that.

Rich
 
Back
Top