本文介绍了在列表视图中为每一行填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在列表视图中搜索,并且我正在使用column16来填充objdatareader试图读取column15的部门名称的记录,这是每行的部门ID,现在我想要的只是识别第15列知道部门名称
问题是当我填充记录时它将水平显示,但我想要垂直显示...
这是我的示例代码
i am trying to search in listview and i am using column16 to populate the record for the department name the objdatareader is trying to read column15 it''s a deparment id for each row, now all i want is to identify column 15 to know the department name
the problem is when i populate the record it will display horizontally but i want is vertically...
here''s my sample code
Dim objDataReader As OleDbDataReader
objDataReader = objCommand.ExecuteReader
If objDataReader.HasRows = 0 Then
txtCostCenter.Text = ""
txtDivision.Text = ""
End If
While objDataReader.Read
For Each item2 As ListViewItem In lstLicense.Items
With item2
item2.SubItems.Add(16).Text = (objDataReader("Division")).ToString
End With
Next
' Next
End While
Dim v As Integer
Dim aa As ListViewItem
lstCostCenter.Items.Clear()
Dim strSQL As String
For Each item2 As ListViewItem In lstLicense.Items
strSQL = "SELECT * FROM tblEndUserDetails WHERE CostCenter Like '" & item2.SubItems(15).Text & "%'"
classLibrary = New ConLib
classLibrary.openConnection(strConnection)
lblconstat.Text = DatabaseStatus
If Not classLibrary.isconnectionopen() Then
Exit Sub
End If
classLibrary.initializeCommand(strSQL)
populateDatAddCostCenterPopUpBox3()
Next
End Sub
推荐答案
lstLicense.Items.Insert(16, (objDataReader("Division")).ToString)
<pre lang="vb">
Dim v As Integer
Dim aa As ListViewItem
lstCostCenter.Items.Clear()
Dim strSQL As String
For Each item2 As ListViewItem In lstLicense.Items
strSQL = "SELECT * FROM tblEndUserDetails WHERE CostCenter Like '" & item2.SubItems(15).Text & "%'"
classLibrary = New ConLib
classLibrary.openConnection(strConnection)
lblconstat.Text = DatabaseStatus
If Not classLibrary.isconnectionopen() Then
Exit Sub
End If
classLibrary.initializeCommand(strSQL)
populateDatAddCostCenterPopUpBox3()
Next
这篇关于在列表视图中为每一行填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!