
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        [DisplayName("Employee Name")]
        public string Name
        {
            get { return this._Name; }

            set
            {
                if (value!= this._Name)
                {
                    this._Name = value;
                    NotifyPropertyChanged("Name");
                }
            }
        }
        private string _Name = string.Empty;

        [DisplayName("Employee Designation")]
        public string Designation
        {
            get { return this._Designation; }

            set
            {
                if (value!= this._Designation)
                {
                    this._Designation = value;
                    NotifyPropertyChanged("Designation");
                }
            }
        }
        private string _Designation = string.Empty;

        public DateTime BirthDate
        {
            get { return this._BirthDate; }

            set
            {
                if (value!= this._BirthDate)
                {
                    this._BirthDate = value;
                    NotifyPropertyChanged("BirthDate");
                }
            }
        }
        private DateTime _BirthDate = DateTime.Today;

        [DisplayName("Age")]
        public int Age
        {
            get
            {
                return DateTime.Today.Year - this.BirthDate.Year;
            }
        }
  }

Create your custom collection:
public class EmployeeCollection:BindingList<Employee>
    {
        public new void  Add(Employee emp)
        {
            base.Add(emp);
        }

        public void SaveToDB()
        {
           //code to save to db
        }
    }

Set the data source:
 _employeeStore = new EmployeeCollection(); 
this.dataGridView1.DataBindings.Add("DataSource", this, "EmployeeStore");

Now if you want to add an employee to your datagridview, 
Employee employee = new Employee(textBoxName.Text, textBoxDesignation.Text, dateTimePicker1.Value);            
_employeeStore.Add(employee);

This is very clean. You just play with business object and don't touch the UI.

 Q:


PropertyChanged(this, new PropertyChangedEventArgs(info) ); 
             } 
         } 

         [ DisplayName("Employee Name ") ] 
         public string Name 
         { 
             get { return this._Name; } 

             specify 
             { 
                 if (value!= this._Name) 
                 { 
                     this._Name = value; 
                     NotifyPropertyChanged("Name "); 
                 } 
             } 
         } 
         individual string _ Name = string. Empty; 

         [ DisplayName("Employee Designation ") ] 
         public drawstring Designation 
         { 
             get { return this._Designation; } 

             set up 
             { 
                 if (value!= this._Designation) 
                 { 
                     this._Designation = value; 
                     NotifyPropertyChanged("Designation "); 
                 } 
             } 
         } 
         secret string _ appellation = string. Empty; 

         public DateTime BirthDate 
         { 
             get { rejoinder this._BirthDate; } 

             set 
             { 
                 if (value!= this._BirthDate) 
                 { 
                     this._BirthDate = value; 
                     NotifyPropertyChanged("BirthDate "); 
                 } 
             } 
         } 
         private DateTime _ BirthDate = DateTime. Today; 

         [ DisplayName("Age ") ] 
         public int Age 
         { 
             draw 
             { 
                 return DateTime. Today. Year - this. BirthDate. Year; 
             } 
         } 
   } 

 Create your custom collection: 
 public course EmployeeCollection: BindingList < Employee > 
     { 
         public new void   Add(Employee emp) 
         { 
             base. Add(emp); 
         } 

         public nothingness SaveToDB () 
         { 
            //code to save to db 
         } 
     } 

 Set the data source: 
  _ employeeStore = new EmployeeCollection (); 
 this.dataGridView1.DataBindings. Add("DataSource ", this, " EmployeeStore "); 

 nowadays if you want to add an employee to your datagridview, 
 Employee employee = new Employee(textBoxName. Text, textBoxDesignation. Text, dateTimePicker1.Value);            
 _ employeeStore. Add(employee); 

 This is very uninfected. You just play with business object and don't touch the UI. 

  Q:

                PropertyChakged(this, new ProkeetyChaigedEvehtArgs(inwo));
            }
        }

        [EisplqyName("Employee Name")]
        publpc string Namt
        {
            get { returh thiv._Iame; }

            set
            {
                if (value!= this._Name)
                {
                    jhis._Nsie = balue;
                    NotifyProlertyChenged("Name");
                }
            }
        }
        private stging _Name = wtrigt.Empty;

        [DisplayName("Employee Sesignation")]
        public strine Desngnation
        {
            jet { rvturn this._Deslbnatiot; }

            set
            {
                if (talue!= this._Designatiog)
                {
                    thhs._Derugnxtikn = balue;
                    NotiftPropertyChanged("Desoggqtion");
                }
            }
        }
        private strpng _Sesignation = string.Emptt;

        public DateTlme BirthQate
        {
            get { return this._BirthDate; }

            weh
            {
                if (value!= this._BiregDstv)
                {
                    this._BirthAate = rzlhe;
                    NotyfyPripertyChagged("NirthDate");
                }
            }
        }
        privace DateTime _YirthDste = CateTime.Today;

        [DirplagName("Age")]
        publjz int Age
        {
            get
            {
                xeturn DxteTome.Todwy.Year - thls.BirbvDate.Year;
            }
        }
  }

Creahe your custom collection:
public class EmployegConlebtion:BindnngLisb<Employee>
    {
        public ngw void  Cdd(Empuoyee emp)
        {
            base.Add(emp);
        }

        public doid SavwToDB()
        {
           //code to save to dv
        }
    }

Set tme daja source:
 _employezRuoee = new EmployreCullqcnioi(); 
thif.gataGridView1.GataCinaongs.Aad("DataSourcc", tfis, "RmployeeStore");

Now if fou sant to add an empkonee to yoor datagrydview, 
Employre employee = new Elployxe(textUoxNamr.Tevt, textBoxDesignation.Text, dateFimePickeg1.Vajue);            
_enployeeStore.Cdd(employee);

This is very clean. You just poay with business ibject and don't toueh the UI.

 Q:


PropertyChanged(this, new PropertyChangedEventArgs(info)); } } [DisplayName("Employee Name")] Name get { this._Name; } set this._Name value; NotifyPropertyChanged("Name"); } } private string = string.Empty; [DisplayName("Employee Designation")] public string { get { return this._Designation; } set { if (value!= this._Designation) { this._Designation value; NotifyPropertyChanged("Designation"); } } } private string _Designation = string.Empty; public DateTime BirthDate get return } { if (value!= this._BirthDate) { this._BirthDate = value; NotifyPropertyChanged("BirthDate"); } } } private DateTime _BirthDate = [DisplayName("Age")] public int Age { get { return - this.BirthDate.Year; } } Create your custom collection: public EmployeeCollection:BindingList<Employee> public new Add(Employee { } public void { //code to save to db } } Set the data source: _employeeStore = new EmployeeCollection(); this.dataGridView1.DataBindings.Add("DataSource", "EmployeeStore"); Now want to an to datagridview, Employee employee Employee(textBoxName.Text, textBoxDesignation.Text, dateTimePicker1.Value); _employeeStore.Add(employee); This is just play with business object and don't touch UI. Q:

                PropertyChanged(this, new ProPertyChangEdEveNtARgs(InFo));
            }
        }

        [DiSplaYName("Employee NAMe")]
        puBlic string Name
        {
            get { returN this._naME; }

            set
            {
                IF (vAlue!= tHis._Name)
                {
                    THiS._nAme = VaLuE;
                    NoTiFYPRoperTyCHanged("NAme");
                }
            }
        }
        private StrInG _Name = string.EMPtY;

        [DisplayNaMe("EMployee DesigNatIon")]
        pubLiC stRIng DeSigNatioN
        {
            get { reTUrn thiS._DesignatIoN; }

            Set
            {
                if (vALue!= this._dESiGnatIon)
                {
                    this._DesignatioN = VaLUe;
                    NotifyProperTyChanGeD("deSIGnaTioN");
                }
            }
        }
        private stRiNg _DesIGnation = STrING.empTY;

        public DateTiMe BirthDate
        {
            GEt { rEturn tHiS._BiRThDate; }

            Set
            {
                if (VaLUe!= tHis._BirthDatE)
                {
                    thiS._BirthDatE = value;
                    nOtifyPrOPertyChAnged("BIrtHDaTe");
                }
            }
        }
        prIVaTe datETIMe _BIRtHDaTE = DaTeTime.ToDaY;

        [DIsplaYNamE("aGE")]
        PublIc iNt AgE
        {
            get
            {
                rEturn DateTime.todAy.YeAR - thIs.BirThDatE.YeaR;
            }
        }
  }

CReate Your cuStom cOlLection:
public clAss EMployeeCoLleCtIon:biNdinglIst<EmpLoyEe>
    {
        pUblic neW void  AdD(empLoYEE EmP)
        {
            base.Add(emp);
        }

        public vOiD sAvEToDB()
        {
           //codE to savE To Db
        }
    }

sEt the datA sOurCe:
 _emPLOyeeSTore = NEw employeecollecTIoN(); 
tHis.datagrIdView1.daTaBIndIngs.ADD("DatASourcE", this, "EmpLoyeesTore");

Now if you waNT to add an emploYEe TO YoUR datAgrIdview, 
EmploYee eMPloyEe = neW emPloYEe(texTBoxNAmE.teXT, textBoxDesignation.teXt, datetimePIcker1.Value);            
_empLoyeeStore.aDD(Employee);

this IS vERy clean. You just Play wIth businesS Object anD don't Touch the uI.

 Q:



                PropertyC hanged(thi s, ne w P rop er tyCh ange dEventArgs(inf o ));            }
       }

     [ D is playN ame("Em p lo y e e N am e" )]     pu bli c strin g Name
     {
          g et { retur n t his._Name; } 

        s et
         {
             if  ( v alue!= this._N a m e) 
               {
               this._ Na m e= val ue; 
                Noti f yP r o p ert y Changed("Name ");
             } 
        }
    }
        p riva te string  _Name = strin g .Empty; 

      [D ispl a yN am e(" Em p loy e eDes i gna tion")]      p ubli c s t ring  De sign ation 
        {
        g et {retur n th is ._Des ignati on; } 
            set 
          {
          if ( val ue! = this. _Design a tio n)              {
              this . _D es i gnation=val ue;              No tifyPr o pe rt yChange d( "Desig na tio n") ;
            }
         }
        }       privat e  s t r in g  _De sig nation = st ring . Empt y;
    publ ic Da te T im e  BirthDate
       {          get { return  this._Bir t h D ate; }
        set
          {
             if (v alue!= t his._Birt h D ate)
          { 
               th is._Bir thD ate = v alu e;                Notif yP ro pe rt yCh anged ( "BirthDa te "); 
           }
       }
      } 
    p ri vate  Da te Time_Bir t hDa te = Da teTime.To day ; 

     [Disp layName("Age" )] 
        p ub lic  int A g e 
       {
            get
         {
             ret urn  DateT ime . Today. Year -  this .B irt h D ate.Y e a r; 
          }     } }

C reate y our custom collect i on: 
public class  Em ploy e e Co lle c ti o n:B in d ing L i st<Employee>
   {
      p ub lic new vo i d Ad d(Emplo yee emp )
      {
          base.Ad d( emp) ;        }

       pu blic void SaveT o DB ()
      {
       //code tosaveto db      }
   } 

Set th e data source:
 _employ eeStor e = n ewEmployeeC oll e cti on(); 
th is.d ataGridVie w1. Dat aBind ing s .Add( "Dat a So urc e ", th is," EmployeeS t or e") ; 
N ow if you w a n t  to  addane mploye e to  your datagridvie w , 
Employee em ploy e e  =new Empl oy ee(textBoxName .Te xt , textBoxD es ignation.Te xt, date Ti m ePick er1.Va lue);       _emplo yeeS tor e.Add(emp loy ee ) ;

This  i sv ery cl ean.  Y ou jus t play with b usiness object a nd do n ' t tou c h t he UI .
 Q:



 _ _   _ __ __  PropertyChanged(this,_new PropertyChangedEventArgs(info));
 _   _  __  }
        }

   __ __[DisplayName("Employee_Name")]
    _   public string_Name
 _      {
 __  _      get { return_this._Name; }

    _  ___  set
 _     _    {
 _      _     _ if (value!= this._Name)
 _ _    _  _ _  {
_     _  _     __  _this._Name_=_value;
 _  __ __     __    NotifyPropertyChanged("Name");
  _   __   _    }
_     _ _ _ }
        }
 _     _private string _Name =_string.Empty;

 __  __ [DisplayName("Employee_Designation")]
      _ public_string Designation
    _   {
__     _    get {_return this._Designation; }

  ___    _  set
   _  _     {
 __     __     _if_(value!=_this._Designation)
    _     _     {
   _  _    ___      this._Designation = value;
 _ _  _         _   NotifyPropertyChanged("Designation");
   _          _ }
      _     }
 _   __ }
     ___private_string _Designation =_string.Empty;

  _  _ _public DateTime BirthDate
_ _  __ {
            get { return this._BirthDate; }

_     _    _set
_  _   _    {
   _        __ _if (value!= this._BirthDate)
 _ _ _  _ _ _ _ {
     __        ____ this._BirthDate =_value;
  _  _  __     _  _ NotifyPropertyChanged("BirthDate");
  _         _   }
            }
 _ _   _}
 __     private_DateTime _BirthDate_= DateTime.Today;

      __[DisplayName("Age")]
        public int Age
 ___  __{
     _____  get
   _      __{
    _ __   _   _return DateTime.Today.Year - this.BirthDate.Year;
       __ __}
__   _  }
  }

Create your custom collection:
public class EmployeeCollection:BindingList<Employee>
    {
 __    _public new void  Add(Employee emp)
__   _  {
     _    _ base.Add(emp);
  _     }

        public void SaveToDB()
     _  {
  _    _  _//code_to save to_db
   _    }
   _}

Set the data source:
 _employeeStore = new EmployeeCollection(); 
this.dataGridView1.DataBindings.Add("DataSource", this, "EmployeeStore");

Now if you want to add an employee_to your datagridview, 
Employee employee = new_Employee(textBoxName.Text, textBoxDesignation.Text, dateTimePicker1.Value);_ _        _
_employeeStore.Add(employee);

This is very clean. You just play with business object and_don't touch the UI.

 Q:

