Public Sub FillListView(ByVal sqlData As DataTable, ByVal lvList As ListView, ByVal imageID As Integer)
Dim i As Integer
Dim j As Integer
lvList.Clear()
For i = 0 To sqlData.Columns.Count - 1
lvList.Columns.Add(sqlData.Columns(i).ColumnName)
Next i
For i = 0 To sqlData.Rows.Count - 1
lvList.Items.Add(sqlData.Rows(i).Item(0), imageID)
For j = 1 To sqlData.Columns.Count - 1
If Not IsDBNull(sqlData.Rows(i).Item(j)) Then
lvList.Items(i).SubItems.Add(sqlData.Rows(i).Item(j))
Else
lvList.Items(i).SubItems.Add("")
End If
Next j
Next i
For i = 0 To sqlData.Columns.Count - 1
xsize = lvList.Width / sqlData.Columns.Count - 8
lvList.Columns(i).Width = xsize
Next i
End Sub
Public Sub FillListView(ByVal sqlData As DataTable, ByVal dgv As DataGridView)
dgv.Columns.Clear()
dgv.AutoGenerateColumns = False
For i As Integer = 0 To sqlData.Columns.Count - 1
dgv.Columns.Add(sqlData.Columns(i).ColumnName , sqlData.Columns(i).ColumnName)
dgv.Columns(i).DataPropertyName = sqlData.Columns(i).ColumnName
Next i
dgv.DataSource = sqlData
End Sub