Option Explicit
Private Sub CommandButton3_Click()
End Sub
Private Sub CommandButton4_Click()
Dim X As Integer
For X = 1 To ListView1.ListItems.Count
ListView1.ListItems(X).Selected = False
ListView2.ListItems(X).Selected = False
Next
Set ListView1.SelectedItem = Nothing
Set ListView2.SelectedItem = Nothing
End Sub
Private Sub TextBox1_Change()
Call LVW_Fill(Trim$(TextBox1.Text), ComboBox1.ListIndex)
End Sub
Private Sub UserForm_Activate()
Me.Caption = "Interrogation Cheptel"
With Selection
With .ListView1
.CheckBoxes = True
.AllowColumnReorder = True
Set .Icons = ImageList1
Set .SmallIcons = ImageList1
End With
With .ListView2
.ColumnHeaders.Clear
.ColumnHeaders.Add , , "N°", 30
.ColumnHeaders.Add , , "Poulailler", 45
.ColumnHeaders.Add , , "Sexe", 55
.ColumnHeaders.Add , , "Race", 55
.ColumnHeaders.Add , , "Couleur", 55
.ColumnHeaders.Add , , "Naissance", 55
.ColumnHeaders.Add , , "Acquisition", 55
.ColumnHeaders.Add , , "Prix", 55
.ColumnHeaders.Add , , "Sortie", 55
.ColumnHeaders.Add , , "jours présence", 55
.ColumnHeaders.Add , , "Soies", 55
.ColumnHeaders.Add , , "Naissance", 55
.ColumnHeaders.Add , , "30 jours et plus", 55
.ColumnHeaders.Add , , "Plus de 2 ans", 55
.ColumnHeaders.Add , , "Pondeuse", 55
.ColumnHeaders.Add , , "moins de 30 jours", 55
.ColumnHeaders.Add , , "Abattus", 55
.ColumnHeaders.Add , , "Perdus", 55
.ColumnHeaders.Add , , "Poids", 55
.ColumnHeaders.Add , , "Notes", 55
.ColumnHeaders.Add , , "Coul. Tête", 55
.ColumnHeaders.Add , , "Coul. Queue", 55
.ColumnHeaders.Add , , "Particularités", 55
.ColumnHeaders.Add , , "Nom", 55
.ColumnHeaders.Add , , "Vendu", 55
.ColumnHeaders.Add , , "Date", 55
.ColumnHeaders.Add , , "N° Lot", 55
.ColumnHeaders.Add , , "Notes abattage", 55
.ColumnHeaders.Add , , "Age en jours", 55
.FullRowSelect = True
.ListItems.Clear
.View = lvwReport
End With
End With
Call CBO_Fill
Call LVW_Fill("", 0)
End Sub
' ------ Tri lors de la sélection d'une colonne ----------
Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
ListView1.Sorted = False
ListView1.SortKey = ColumnHeader.Index - 1
If ListView1.SortOrder = lvwAscending Then
ListView1.SortOrder = lvwDescending
Else
ListView1.SortOrder = lvwAscending
End If
ListView1.Sorted = True
End Sub
Private Sub CommandButton2_Click()
Unload Me
SuiviSanitaire.Show
End Sub
Private Sub CBO_Fill()
'Variables locales
Dim iCnt As Integer
Dim oRng As Excel.Range
'Remplit la Combo
Set oRng = Feuil2.Cells(1, 1)
For iCnt = 0 To 34 '-- 33 colonnes
ComboBox1.AddItem oRng.Offset(0, iCnt)
Next iCnt
ComboBox1.ListIndex = 0
End Sub
Private Sub ListView1_ItemCheck(ByVal Item As MSComctlLib.ListItem)
Dim j As Integer
If Item.Checked = True Then
Item.ForeColor = RGB(0, 0, 255) 'Changement couleur
Item.Bold = True 'Gras
For j = 1 To Item.ListSubItems.Count
Item.ListSubItems(j).ForeColor = RGB(0, 0, 0)
Item.ListSubItems(j).Bold = True
Next j
Else
Item.ForeColor = RGB(1, 0, 0) 'Changement couleur
Item.Bold = False
For j = 1 To Item.ListSubItems.Count
Item.ListSubItems(j).ForeColor = RGB(1, 0, 0)
Item.ListSubItems(j).Bold = False
Next j
End If
End Sub
Private Sub LVW_Fill(ByVal sFilter As String, ByVal iCol As Integer)
'Variables locales
Dim iCnt As Integer
Dim iRnd As Integer
Dim oRng As Excel.Range
Dim oItem As ListItem
'Initialisation de la ListView
ListView1.ColumnHeaders.Clear
ListView1.FullRowSelect = True
ListView1.ListItems.Clear
ListView1.View = lvwReport
'Remplissage de la ListView
Set oRng = Feuil2.Cells(1, 1)
Do Until oRng.Offset(1, 0).Value = ""
'-- En-têtes
If oRng.Row = 1 Then
For iCnt = 0 To 32 '-- 33 colonnes
ListView1.ColumnHeaders.Add , , oRng.Offset(0, iCnt)
Next iCnt
'-- Données
Else
iRnd = Int((4 * Rnd) + 1)
If LCase$(Left$(oRng.Offset(0, iCol), Len(sFilter))) = LCase$(sFilter) Then
Set oItem = ListView1.ListItems.Add(, , oRng.Offset(0, 0), "Key" & iRnd, "Key" & iRnd)
For iCnt = 1 To 33 '-- 33 colonnes
oItem.ListSubItems.Add , , oRng.Offset(0, iCnt)
Next iCnt
End If
End If
Set oRng = oRng.Offset(1, 0)
Loop
End Sub
Private Sub CommandButton5_Click()
Dim lgn As Integer
Dim LstVitem As Object
With Selection
For lgn = 1 To .ListView1.ListItems.Count
Set LstVitem = .ListView1.ListItems(lgn)
With LstVitem
If .Checked = True Then
Selection.ListView2.ListItems.Add , , .Text
Selection.ListView2.ListItems(Selection.ListView2.ListItems.Count).ListSubItems.Add , , .ListSubItems(1).Text
.Checked = False
End If
End With
Next lgn
End With
End Sub
Private Sub CommandButton1_Click()
Dim c As Control
For Each c In Me.Controls
Select Case TypeName(c)
Case "TextBox"
c.Value = ""
Case "ListBox", "ComboBox"
c.Value = ""
ListView1.ListItems.Clear
c.Value = ""
End Select
Next c
End Sub
'Private Sub CommandButton2_Click() 'bouton "Quitter"
'Unload Me 'vide et ferme l'UserFOrm
'End Sub