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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
Private Sub myPD_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles myPD.PrintPage
If nb_cat = 0 Then
e.HasMorePages = False
ElseIf nb_cat = 1 Then
'récuperation du nom de la seule cat
Dim nom_cat As String = dt_cat_off.Rows(0).Item("nom_cat")
'je suppose qu'il y a tjrs un panel avec le nom de la cat
'd'où le contrôle panel de cette catégorie
Dim la_cat As Control
For Each ctl As Control In Me.Controls
If TypeOf (ctl) Is Panel And ctl.Name = nom_cat Then
la_cat = ctl
End If
Next
'puis les contrôles de ce panel
For Each ctl2 As Control In la_cat.Controls
e.Graphics.DrawString(ctl2.Text, SystemFonts.DefaultFont, Brushes.RoyalBlue, ctl2.Left, _
ctl2.Top)
Next
'suppression ds dt_cat_off de cette cat
Dim dt_a_eff As DataSet1.catRow = ta_cat. _
get_cat_sup(la_cat.Name, supermarche.nom_sup).Rows(0)
dt_cat_off.RemovecatRow(dt_a_eff)
e.HasMorePages = False
ElseIf nb_cat >= 2 Then
Dim nom_cat1 As String = dt_cat_off.Rows(0).Item("nom_cat")
'je suppose qu'il y a tjrs un panel avec le nom de la cat
'd'où le contrôle panel de cette catégorie
Dim la_cat1 As Control
For Each ctl As Control In Me.Controls
If TypeOf (ctl) Is Panel And ctl.Name = nom_cat1 Then
la_cat1 = ctl
End If
Next
Dim nom_cat2 As String = dt_cat_off.Rows(1).Item("nom_cat")
'je suppose qu'il y a tjrs un panel avec le nom de la cat
'd'où le contrôle panel de cette catégorie
Dim la_cat2 As Control
For Each ctl As Control In Me.Controls
If TypeOf (ctl) Is Panel And ctl.Name = nom_cat2 Then
la_cat2 = ctl
End If
Next
'2e étape
'puis les contrôles de ce panel
For Each ctl2 As Control In la_cat1.Controls
e.Graphics.DrawString(ctl2.Text, SystemFonts.DefaultFont, Brushes.RoyalBlue, ctl2.Left, _
ctl2.Top)
Next
'suppression ds dt_cat_off de cette cat
Dim dt_a_eff As DataSet1.catRow = ta_cat. _
get_cat_sup(la_cat1.Name, supermarche.nom_sup).Rows(0)
dt_cat_off.Rows.Remove(dt_a_eff)
'3e étape
'puis les contrôles de ce panel
For Each ctl2 As Control In la_cat2.Controls
e.Graphics.DrawString(ctl2.Text, SystemFonts.DefaultFont, Brushes.RoyalBlue, 400 + ctl2.Left, _
ctl2.Top)
Next
'suppression ds dt_cat_off de cette cat
Dim dt_a_eff2 As DataSet1.catRow = ta_cat. _
get_cat_sup(la_cat2.Name, supermarche.nom_sup).Rows(0)
dt_cat_off.RemovecatRow(dt_a_eff2)
e.HasMorePages = True
End If
End Sub |
Partager