代码如下:
Public Class HistoricalData
Dim i As Integer
Dim n As Integer
Dim listItem As New ListViewItem
Private Sub HisData_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
ListView1.Clear() '清空列表
ListView1.Columns.Clear() '清空列表头
ListView1.View = View.Details '设置列表显示方式
ListView1.FullRowSelect = True '选择整行
ListView1.Columns.Add("序号", 40, HorizontalAlignment.Center) '给列表中添加列名
ListView1.Columns.Add("温度", 70, HorizontalAlignment.Center)
ListView1.Columns.Add("湿度", 70, HorizontalAlignment.Center)
ListView1.Columns.Add("光照度", 80, HorizontalAlignment.Center)
ListView1.Columns.Add("CO2浓度", 80, HorizontalAlignment.Center)
ListView1.Columns.Add("时间", 150, HorizontalAlignment.Center)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For i = 0 To 119
listItem.SubItems.Add(i + 1)
listItem.SubItems.Add(Tem(i))
listItem.SubItems.Add(Hum(i))
listItem.SubItems.Add(Lux(i))
listItem.SubItems.Add(CO2Con(i))
listItem.SubItems.Add(Now)
ListView1.Items.Add(listItem)
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Hide()
End Sub
End Class