打印本文 打印本文 关闭窗口 关闭窗口
把sql字符串中选择的内容显示在ListView
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2527  更新时间:2007/11/14 12:02:17  文章录入:mintao  责任编辑:mintao

                ''''[加入每一列数据]
                ListView1.Items.Clear()

                Dim iRow As Long = 0
                Dim iRowHead As Int16

                While oleReader.Read()
                    ListView1.Items.Add(oleReader(0))
                    For iRowHead = 1 To oleReader.FieldCount - 1
                        If oleReader(irowhead) Is System.DBNull.value = False Then
                            ListView1.Items(iRow).SubItems.Add(CStr(oleReader(iRowHead)))
                        Else
                            ListView1.Items(irow).SubItems.Add(" ")
                        End If
                    Next
                    iRow = iRow + 1
                End While
            Catch
                MessageBox.Show(Err.Description, clewInfo, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                oleConn.Close()
                Exit Sub
            End Try

            oleReader.Close()
            oleCmd.Dispose()
            oleConn.Close()

        End If

        ''''【加入底色】
        Dim i As Integer
        For i = 0 To ListView1.Items.Count - 1
            If i Mod 2 = 0 Then
                ListView1.Items(i).BackColor = Color.LightBlue
            Else
                ListView1.Items(i).BackColor = Color.OldLace
            End If
        Next i

        ''''[是否显示check按钮]
        If check = True Then
            ListView1.CheckBoxes = True
        Else
            ListView1.CheckBoxes = False
        End If
    End Sub

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口