DBGrid Sort
Posted: 2002-06-01
By: ArchiveBot
Viewed: 122
Filed Under:
No attachments for this post
It is nice technique for dbgrid sorting.You
can sort Dbgrid Columns by clicking on the grid column header
in two ways ascending or descending.
Original Author: Adam Abas
Returns
Sorted Records in dbgrid.
Side Effects
No Idea,
API Declarations
Code
Option Explicit
Dim st As Boolean
***********************
Private Sub DBGrid1_HeadClick(ByVal ColIndex As Integer)
'Dbgrid Columns sort by clicking the grid header in two way ascending and descending
If st = True Then
DBGrid1.HoldFields
Data1.RecordSource = " Select * from Authors Order By " & DBGrid1.Columns(ColIndex).DataField
Data1.Refresh
DBGrid1.ReBind
Else
DBGrid1.HoldFields
Data1.RecordSource = " Select * from Authors Order By " & DBGrid1.Columns(ColIndex).DataField & " DESC "
Data1.Refresh
DBGrid1.ReBind
End If
st = Not st
End Sub
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.