我的程序里的一段,刚好符合你的要求:Private Sub dgOverTime_HeadClick(ByVal ColIndex As Integer) With DEAttend.rsOverTime If .State Then Select Case ColIndex Case 0 If .Sort = "ticketno" Then .Sort = "ticketno desc" Else .Sort = "ticketno" End If Case 1 If .Sort = "workid" Then .Sort = "workid desc" Else .Sort = "workid" End If Case 2 If .Sort = "name" Then .Sort = "name desc" Else .Sort = "name" End If End Select End If End With
此问题已由我自主解决了!早知如此就不在此散分了!Dim st as integer,ct as integerPrivate Sub Dgd1_HeadClick(ByVal ColIndex As Integer) Dim scol As Integer scol = Dgd1.LeftCol s = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_ App.Path "\data.mdb;Persist Security Info=False" Adc1.ConnectionString = s If ColIndex = st Then ct = ct + 1 Else st = -1 End If If ct Mod 2 = 0 Then Adc1.RecordSource = "select " & b & " from Savings order by " & Dgd1.Columns &_ (ColIndex).Caption Else Adc1.RecordSource = "select " & b & " from Savings order by " & Dgd1.Columns &_ (ColIndex).Caption & " desc" End If Adc1.Refresh Dgd1.Refresh st = ColIndex Dgd1.LeftCol = scol End Sub
With DEAttend.rsOverTime
If .State Then
Select Case ColIndex
Case 0
If .Sort = "ticketno" Then
.Sort = "ticketno desc"
Else
.Sort = "ticketno"
End If
Case 1
If .Sort = "workid" Then
.Sort = "workid desc"
Else
.Sort = "workid"
End If
Case 2
If .Sort = "name" Then
.Sort = "name desc"
Else
.Sort = "name"
End If
End Select
End If
End With
你用过其他的网格控件吗?
Dim scol As Integer
scol = Dgd1.LeftCol
s = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_
App.Path "\data.mdb;Persist Security Info=False"
Adc1.ConnectionString = s
If ColIndex = st Then
ct = ct + 1
Else
st = -1
End If
If ct Mod 2 = 0 Then
Adc1.RecordSource = "select " & b & " from Savings order by " & Dgd1.Columns &_
(ColIndex).Caption
Else
Adc1.RecordSource = "select " & b & " from Savings order by " & Dgd1.Columns &_
(ColIndex).Caption & " desc"
End If
Adc1.Refresh
Dgd1.Refresh
st = ColIndex
Dgd1.LeftCol = scol
End Sub
但是,我觉得,不应该发牢骚,大家切磋技艺吗??
你觉得呢?