Advertisement
4_2005-2006 Databases/ Data Access/ DAO/ ADO #153238

DataGrid Sort

Sorts the records in a datagrid form when clicking on the column header. Toggles between ascending/descending sort order.

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
Private Sub grdDataGrid_HeadClick(ByVal ColIndex As Integer)
 Dim strColName As String
 Static bSortAsc As Boolean
 Static strPrevCol As String
 
 strColName = grdDataGrid.Columns(ColIndex).DataField
 
' Did the user click again on the same column ? If so, check
' the previous state, in order to toggle between sorting ascending
' or descending. If this is the first time the user clicks on a column
' or if he/she clicks on another column, then sort ascending.
 If strColName = strPrevCol Then
  If bSortAsc Then
   adoPrimaryRS.Sort = strColName & " DESC"
   bSortAsc = False
  Else
   adoPrimaryRS.Sort = strColName
   bSortAsc = True
  End If
 Else
  adoPrimaryRS.Sort = strColName
  bSortAsc = True
 End If
   
 strPrevCol = strColName
End Sub
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine