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;
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace TestingListe
- {
- class lstContacts
- {
- public static List
ct = new List(); - public lstContacts()
- {
- }
- }
- }
- 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;
- }
and bellow i upload all the project in a .rar file

Bikesh SrivastavaPosted Oct 17, 2016, 9:23 AM