Advertisement
Java_Volume1 Databases/ Data Access/ DAO/ ADO #90490

DBGrid Sort

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.

AI

AI 摘要: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

源代码
original-source
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

Upload
Upload
原始评论 (3)
从 Wayback Machine 恢复