首页上一页 1 下一页尾页 1 条记录 1/1页
VB从入门到精通第三版12.33 用listview控件+数据表创建报表视图 从哪添加房间信息啊,求高人指点
发表在VB答疑区
2016-09-15
是否精华
是
否
版块置顶:
是
否
Option Explicit
Private Sub Form_Load()
'建立一个ADO数据连接
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
'建立一个连接字符串
'这个连接串可能根据数据库配置的不同而不同
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_kfgl.mdb;Persist Security Info=False"
'建立数据库连接
cnn.Open
rs.Open "select * from kf", cnn
If rs.EOF Then Exit Sub
'网格行
ListView1.GridLines = True
'采用报表显示模式
ListView1.View = lvwReport
Dim ListX As ListItem
Dim ListSubX As ListSubItem
Dim ColumnX As ColumnHeader
Dim i As Integer
'填充表头
For i = 0 To rs.Fields.Count - 1
Set ColumnX = ListView1.ColumnHeaders.Add
ColumnX.Text = rs.Fields(i).Name
ColumnX.Width = ListView1.Width / rs.Fields.Count
Next i
'填充数据
Do Until rs.EOF
'添加一行
Set ListX = ListView1.ListItems.Add
ListX.Text = rs.Fields(0).Value
For i = 1 To rs.Fields.Count - 1
Set ListSubX = ListX.ListSubItems.Add
ListSubX.Text = rs.Fields(i).Value
Next i
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
cnn.Close
Set rs = Nothing
End Sub
请问怎样添加房间号、房间类型、楼层、房态等文字信息以及下面的行信息?
Private Sub Form_Load()
'建立一个ADO数据连接
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
'建立一个连接字符串
'这个连接串可能根据数据库配置的不同而不同
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_kfgl.mdb;Persist Security Info=False"
'建立数据库连接
cnn.Open
rs.Open "select * from kf", cnn
If rs.EOF Then Exit Sub
'网格行
ListView1.GridLines = True
'采用报表显示模式
ListView1.View = lvwReport
Dim ListX As ListItem
Dim ListSubX As ListSubItem
Dim ColumnX As ColumnHeader
Dim i As Integer
'填充表头
For i = 0 To rs.Fields.Count - 1
Set ColumnX = ListView1.ColumnHeaders.Add
ColumnX.Text = rs.Fields(i).Name
ColumnX.Width = ListView1.Width / rs.Fields.Count
Next i
'填充数据
Do Until rs.EOF
'添加一行
Set ListX = ListView1.ListItems.Add
ListX.Text = rs.Fields(0).Value
For i = 1 To rs.Fields.Count - 1
Set ListSubX = ListX.ListSubItems.Add
ListSubX.Text = rs.Fields(i).Value
Next i
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
cnn.Close
Set rs = Nothing
End Sub
请问怎样添加房间号、房间类型、楼层、房态等文字信息以及下面的行信息?