vb中listview数据累加
网上的一些实例都是查询后listview的数据就被清理了如何不清理上次查询的结果继续累加呢?PrivateSubcmdQuery_Click()DimstrSQLAsSt...
网上的一些实例都是查询后listview的数据就被清理了如何不清理上次查询的结果继续累加呢?
Private Sub cmdQuery_Click()
Dim strSQL As String
'查询不能为空
If Trim(txtName.Text) = "" Then
MsgBox "查询姓名不能为空!", vbOKOnly + vbExclamation, "警告!"
txtName.SetFocus
Exit Sub
End If
strSQL = "Select * From 数据源 Where 经销商 like " _
+ "'" + Replace(Trim(txtName.Text), "'", "''", 1) + "%'"
Adodc1.ConnectionString = ConnectString
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strSQL
Adodc1.Refresh
End Sub 展开
Private Sub cmdQuery_Click()
Dim strSQL As String
'查询不能为空
If Trim(txtName.Text) = "" Then
MsgBox "查询姓名不能为空!", vbOKOnly + vbExclamation, "警告!"
txtName.SetFocus
Exit Sub
End If
strSQL = "Select * From 数据源 Where 经销商 like " _
+ "'" + Replace(Trim(txtName.Text), "'", "''", 1) + "%'"
Adodc1.ConnectionString = ConnectString
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strSQL
Adodc1.Refresh
End Sub 展开
1个回答
展开全部
用弊高喊代码进行说租野一下:
Private Sub Command1_Click()
Dim xx As ListItem
If Text1.Text <> "" And Text2.Text <> "" And Text3.Text <> "" Then
Set xx = ListView1.ListItems.Add(, , Text1.Text)
xx.SubItems(1) = Text2.Text
xx.SubItems(2) = Text3.Text
Set xx = Nothing
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End If
End Sub
Private Sub Form_Load()
ListView1.View = lvwReport
ListView1.ColumnHeaders.Add , , "第1列", 1000
ListView1.ColumnHeaders.Add , , "第2列", 1000
ListView1.ColumnHeaders.Add , , "念旦第3列", 1000
End Sub
Private Sub Command1_Click()
Dim xx As ListItem
If Text1.Text <> "" And Text2.Text <> "" And Text3.Text <> "" Then
Set xx = ListView1.ListItems.Add(, , Text1.Text)
xx.SubItems(1) = Text2.Text
xx.SubItems(2) = Text3.Text
Set xx = Nothing
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End If
End Sub
Private Sub Form_Load()
ListView1.View = lvwReport
ListView1.ColumnHeaders.Add , , "第1列", 1000
ListView1.ColumnHeaders.Add , , "第2列", 1000
ListView1.ColumnHeaders.Add , , "念旦第3列", 1000
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询