hi, my question is about the datagridview. I create a class ctsContacts with this source code:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
-
- namespace TestingListe
- {
- class ctsContacts:lstContacts
- {
- private int _numero;
-
- public int Numero
- {
- get { return _numero; }
- set { _numero = value; }
- }
-
- private string _nom;
-
- public string Nom
- {
- get { return _nom; }
- set { _nom = value; }
- }
- private string _prenom;
-
- public string Prenom
- {
- get { return _prenom; }
- set { _prenom = value; }
- }
- private string _message;
-
- public string Message
- {
- get { return _message; }
- set { _message = value; }
- }
-
-
- public ctsContacts()
- {
-
- }
-
- public ctsContacts(int numero, string nom,string prenom,string message)
- {
- this.Numero = numero;
- this.Nom = nom;
- this.Prenom = prenom;
- this.Message = message;
- }
-
- public bool recherche(int num)
- {
- foreach (ctsContacts search in ct)
- {
- if (search.Numero == num)
- {
- return false;
- }
-
- }
- return true;
-
- }
-
- public bool Ajouter(ctsContacts ctn)
- {
- if (this.recherche(ctn.Numero) == true)
- {
- ct.Add(ctn);
- return true;
- }
- return false;
- }
-
- }
- }
This class inherits another abstract class that contains a list
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
-
- namespace TestingListe
- {
- class lstContacts
- {
- public static List<ctsContacts> ct = new List<ctsContacts>();
- public lstContacts()
- {
-
- }
-
- }
- }
and then in the contact form and add button at this writing source code
- private void btnajouter_Click(object sender, EventArgs e)
- {
- ctsContacts contact = new ctsContacts();
- contact.Numero = int.Parse(txtnumero.Text);
- contact.Nom = txtNom.Text;
- contact.Prenom = txtPrenom.Text;
- contact.Message = txtmesssage.Text;
-
- contact.Ajouter(contact);
-
- dgvcontacts.DataSource = null;
-
- dgvcontacts.DataSource = ctsContacts.ct;
-
- }
the problem is at the datagridview display that copy header right.
and bellow i upload all the project in a .rar file