bonjour je code un petit logiciel qui imprime avec les donnée de ma base sauf que petit soucis il me marque "la référence d'objet n'est pas définie a une instance d'un objet" en cherchant sur internet je ne comprend rien sa fais bientôt 1h30 voir 2h que je suis bloquer dessus pouvez-vous m'aidez s'il vous plait .
Nom : 3.PNG
Affichages : 1244
Taille : 56,1 Ko
mon form de base
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
private void imprimerInterventionToolStripMenuItem_Click(object sender, EventArgs e)
        {
 
            if (listView1.SelectedItems.Count > 0)
            {
                ListViewItem element = listView1.SelectedItems[0];
                string ID = element.SubItems[0].Text;
                string Adresse = element.SubItems[1].Text;
                string Longitude = element.SubItems[2].Text;
                string Latitude = element.SubItems[3].Text;
                string Panne = element.SubItems[4].Text;
                string Date = element.SubItems[5].Text;
                string Erreur = element.SubItems[6].Text;
 
                using (Intervention I = new Intervention()) 
                {
                    I.ID = ID;
                    I.Adresse = Adresse;
                    I.Longitude = Longitude;
                    I.Latitude = Latitude;
                    I.Panne = Panne;
                    I.Date = Date;
                    I.Erreur = Erreur;
 
                    if (I.ShowDialog() == DialogResult.Yes)
                    {
 
                        MySqlCommand cmd = new MySqlCommand("SELECT `iD`, `adresse`, `longitude`, `latitude`, `panne`, `date`, `erreur` FROM `localisation` ", cn);
 
                        cmd.ExecuteNonQuery();
 
 
                    }
                }
            }
        }
mon form qui imprime
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
public string ID { get { return txtPylone.Text; } set { txtPylone.Text = value; } }
        public string Adresse { get { return txtAdresse.Text; } set { txtAdresse.Text = value; } }
        public string Longitude { get { return txtLongitude.Text; } set { txtLongitude.Text = value; } }
        public string Latitude { get { return txtLatitude.Text; } set { txtLatitude.Text = value; } }
        public string Panne { get { return txtPanne.Text; } set { txtPanne.Text = value; } }
        public string Date { get { return txtDate.Text; } set { txtDate.Text = value; } }
        public string Erreur { get { return txtCodeErreur.Text; } set { txtCodeErreur.Text = value; } }
 
        public Intervention()
        {
            InitializeComponent();
 
        }
 
 
        private void btnAnnuler_Click(object sender, EventArgs e)
        {
            Close();
        }
 
        private void btnImprimerBonIntervention_Click(object sender, EventArgs ev )
        {
            timer1.Start();
        }
 
        private void progressBar1_Click(object sender, EventArgs e)
        {
 
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            if(this.progressBar1.Value < 100)
            {
                this.progressBar1.Value = this.progressBar1.Value + 4;
                this.progresselabel.Text = this.progressBar1.Value + "%";
            }else
            {
                timer1.Enabled = false;
                printPreviewDialog1.Document = printDocument1;
                printPreviewDialog1.ShowDialog();
 
 
                printDocument1.Print();
 
 
                MessageBox.Show("Fin d'impression du rapport ");
                DialogResult = DialogResult.Yes;
            }
        }
 
        private void Intervention_Load(object sender, EventArgs e)
        {
 
        }
 
        MySqlConnection cn;
        private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
        {
 
            cn.Open();
 
            string txtTitre = ("Intervention");
            string txtID = ("ID:");
            string txtAdresse = ("Adresse :");
            string txtLongitude = ("Longitude :");
            string txtLatitude = ("Latitude :");
            string txtPanne = ("Panne :");
            string txtDate = ("Date :");
            string txtErreur = ("Code Erreur :");
            string txtSignature = ("Signature du technicien :");
 
            //affichage Titre
            e.Graphics.DrawString(txtTitre, new Font("Arial", 35, FontStyle.Regular), Brushes.Black, new Point(300, 0)); // (--> , haut )
 
 
            //affichage ID
            e.Graphics.DrawString(txtID , new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(10, 150)); 
            e.Graphics.DrawString(ID, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(220, 150));
 
            //Affichage Adresse
            e.Graphics.DrawString(txtAdresse, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(10, 250));
            e.Graphics.DrawString(Adresse, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(220, 250));
 
            //Affichage Longitude
            e.Graphics.DrawString(txtLongitude, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(10, 350));
            e.Graphics.DrawString(Longitude, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(220, 350));
 
            //Affichage Latitude
            e.Graphics.DrawString(txtLatitude, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(10, 450));
            e.Graphics.DrawString(Latitude, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(220, 450));
 
            //Affichage Panne
            e.Graphics.DrawString(txtPanne, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(10, 550));
            e.Graphics.DrawString(Panne, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(220, 550));
 
            //Affichage Date
            e.Graphics.DrawString(txtDate, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(10, 650));
            e.Graphics.DrawString(Date, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(220, 650));
 
            //Affichage Code Erreur
            e.Graphics.DrawString(txtErreur, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(10, 750));
            e.Graphics.DrawString(Erreur, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(220, 750));
 
            //Affichage signature 
            e.Graphics.DrawString(txtSignature, new Font("Arial", 17, FontStyle.Regular), Brushes.Black, new Point(550, 1000));
 
            cn.Close();
je vous remercie d'avance !