1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| Private Sub catchoiceform_Load(sender As Object, e As EventArgs) Handles Me.Load
If dbconn.State = ConnectionState.Open Then
dbconn.Close()
End If
Try
DataGridView1.BackgroundColor = Color.FromArgb(240, 145, 110)
Me.BackColor = Color.FromArgb(20, 20, 20)
ListView1.BackColor = Color.FromArgb(20, 20, 20)
dbconn.Open()
Dim ds As New DataSet
Dim sqladap As New OleDbDataAdapter("SELECT * FROM categorie", dbconn)
sqladap.Fill(ds)
' Dim var1, myfile As String
ListView1.LargeImageList = ImageList1
ListView1.SmallImageList = ImageList1
ListView1.View = View.LargeIcon
ListView1.Columns.Add("Catégorie", 250)
ListView1.Font = New Font(ListView1.Font.FontFamily, 14, ListView1.Font.Style)
Dim i As Integer
Dim lst As ListViewItem
For i = 0 To ds.Tables(0).Rows.Count - 1
If Dir(My.Application.Info.DirectoryPath & "\photos\Categories\" & ds.Tables(0).Rows(i)(0) & ".jpg") <> vbNullString Then
ImageList1.Images.Add(System.Drawing.Image.FromFile(My.Application.Info.DirectoryPath & "\photos\Categories\" & ds.Tables(0).Rows(i)(0) & ".jpg"))
Else
ImageList1.Images.Add(System.Drawing.Image.FromFile(My.Application.Info.DirectoryPath & "\photos\Categories\logo.jpg"))
End If
lst = ListView1.Items.Add(ds.Tables(0).Rows(i)(1), i)
Next
Me.CenterToParent()
Catch ex As Exception
End Try
End Sub |
Partager