Imports System.Data.SqlClient
Public Class FrmCustList

    Private Sub FrmCustList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call opencon()
        'fill()
        fill()
        'filllv()
        filllv2()
        Call closecon()
    End Sub
    
   Private Sub fill()
        With ListView1
            .Columns.Add("ID", 30, HorizontalAlignment.Left)
            .Columns.Add("Room Number", 110, HorizontalAlignment.Left)
            .Columns.Add("Room Charge", 110, HorizontalAlignment.Left)
            .Columns.Add("Room Type", 110, HorizontalAlignment.Left)
            .Columns.Add("No of Extra", 110, HorizontalAlignment.Left)
            .Columns.Add("No of Adult", 110, HorizontalAlignment.Left)
            .Columns.Add("No of Kids", 80, HorizontalAlignment.Left)
            .Columns.Add("Entry Date", 80, HorizontalAlignment.Left)
            .Activation = ItemActivation.OneClick
            .FullRowSelect = True
            .GridLines = True
            .HideSelection = False
            .HoverSelection = False
            .MultiSelect = True
            .View = View.Details
            .HotTracking = False
            .Font = New Font(ListView1.Font.FontFamily, 11, FontStyle.Bold, GraphicsUnit.Pixel)
            .BackColor = Color.White
        End With

    End Sub
   
    Private Sub filllv2()
        Me.ListView1.Items.Clear()
        Try
            Dim myd As New SqlDataAdapter
            With myd
                .SelectCommand = New SqlCommand
                .SelectCommand.CommandText = "SELECT * FROM suj"
                .SelectCommand.Connection = con
            End With
            Dim dh As SqlDataReader
            dh = myd.SelectCommand.ExecuteReader
            Do While dh.Read
                Dim item As New ListViewItem
                item.Text = IIf(dh.IsDBNull(0), " ", dh.Item(0)).ToString
                Dim c As Integer
                For c = 1 To dh.FieldCount - 1
                    If Not dh.IsDBNull(c) Then
                        item.SubItems.Add(dh.Item(c)).ToString()
                    Else
                        item.SubItems.Add(" ")
                    End If
                Next
                Me.ListView1.Items.Add(item)
            Loop
            dh.Close()
        Catch ex As Exception
            MsgBox(ex.Message)

        End Try
    End Sub

    Private Sub Label8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label8.Click
        Me.Close()
    End Sub

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged

    End Sub
End Class