时间:11 地点:22 人物:33 我想显示其中的时间和地点,应该怎么用程序写啊?谢谢各位啦
Private Function SetData(adoRs As ADODB.Recordset, mshgSC As MSHFlexGrid, i As Integer) As Integer
Dim intRow As Integer
SetData = -1
With mshgSC
.Rows = adoRs.RecordCount + 1
For intRow = 0 To adoRs.RecordCount - 1
.TextMatrix(intRow + 1, 1) = TrimNull(adoRs!wzxw)‘字段名
.TextMatrix(intRow + 1, 2) = TrimNull(adoRs!wzsj)
.TextMatrix(intRow + 1, 3) = TrimNull(adoRs!roadname)
.TextMatrix(intRow + 1, 4) = TrimNull(adoRs!Hphm)
.TextMatrix(intRow + 1, 5) = TrimNull(adoRs!Hpzl)
.TextMatrix(intRow + 1, 6) = TrimNull(adoRs!Syr)
.TextMatrix(intRow + 1, 7) = TrimNull(adoRs!Lxdh)
.TextMatrix(intRow + 1, 8) = TrimNull(adoRs!picname)
.TextMatrix(intRow + 1, 9) = TrimNull(adoRs!dbbj)
.TextMatrix(intRow + 1, 10) = TrimNull(adoRs!clbj)
.TextMatrix(intRow + 1, 11) = TrimNull(adoRs!scry)
.TextMatrix(intRow + 1, 12) = TrimNull(adoRs!scyy)
.TextMatrix(intRow + 1, 13) = TrimNull(adoRs!scrq)
If i = 3 Then
.TextMatrix(intRow + 1, 14) = TrimNull(adoRs!edithphm)
.TextMatrix(intRow + 1, 15) = TrimNull(adoRs!edithpzl)
If TrimNull(adoRs!editcarstate) <> "" Then
If TrimNull(adoRs!editcarstate) = 0 Then
.TextMatrix(intRow + 1, 16) = "正常"
ElseIf TrimNull(adoRs!editcarstate) = 1 Then
.TextMatrix(intRow + 1, 16) = "套牌"
.TextMatrix(intRow + 1, 18) = TrimNull(adoRs!tpcllx)
.TextMatrix(intRow + 1, 19) = TrimNull(adoRs!tppclpp)
.TextMatrix(intRow + 1, 20) = TrimNull(adoRs!tpcsys)
End If
End If
.TextMatrix(intRow + 1, 17) = TrimNull(adoRs!editwzxw)
End If
adoRs.MoveNext
Next intRow
End With
SetData = 1
End Function
MSHFlexGrid控件是MSFlexGrid的省级,他们的使用方法很象,你要是只想显示数据为什么不用DataGrid
控件,它直接绑定就可以了
这段代码只是显示时用的,它的题目和长、宽都需要自己设定的
Public Function Ini_Title(mshgJK As MSHFlexGrid) As Integer
Dim intCol As Integer
Ini_Title = -1
With mshgJK
.TextMatrix(0, 0) = "选择"
.TextMatrix(0, 1) = " 违法" & vbCrLf & " 行为"
.ColWidth(0) = 500
.ColWidth(1) = 1000
.MergeCells = flexMergeFree
.MergeCol(1) = True
.ColAlignment(0) = 4
For intCol = 0 To .Cols - 2
.ColAlignment(intCol + 1) = 1
Next intCol
.RowHeight(0) = 500
End With
Ini_Title = 1
End Function
Option Explicit
Public Conn As New ADODb.Connection
Public Rs As New ADODb.Recordset
Private Sub Form_Load()
Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Documents and Settings/Administrator/桌面/aa.mdb;Persist Security Info=False"
Conn.CursorLocation = adUseClient
Conn.Open strConn
Call LoadData
End Sub
'载入数据进入msflexgrid
Public Sub LoadData()
'初始化msflexgrid
With Me.MSFlexGrid1
.Clear
.Cols = 5
.Rows = 1
End With
If Rs.State = 1 Then Rs.Close
Rs.Open "Select * from jobs", Conn, 3, 3
'加入数据并且显示表中指定的3个ID内容
Do While Not Rs.EOF
Me.MSFlexGrid1.AddItem Me.MSFlexGrid1.Rows & Chr(9) _
& Trim(Rs("job_id") & "") & Chr(9) _
& Trim(Rs("job_desc") & "") & Chr(9) _
& Trim(Rs("min_lvl") & "")
Rs.MoveNext
Loop
End Sub