在列表视图中为每一行填充 [英] Populatedata for each row in listview

查看:143
本文介绍了在列表视图中为每一行填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在列表视图中搜索,并且我正在使用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

推荐答案

添加这样的内容.
Add like this.
lstLicense.Items.Insert(16, (objDataReader("Division")).ToString)


我遇到1个错误"Items不是" System.Windows.Forms.ListViewItem"的成员.

实际上我想要显示在column16上,但记录是水平重复的
i have 1 error ''Items is not a member of ''System.Windows.Forms.ListViewItem''.

actually i want is to display at column16 but the record is repeating horizontally


我正在尝试在listview中搜索,并且我正在使用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
<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



这篇关于在列表视图中为每一行填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆