Winform Data Binding

Source: Internet
Author: User
Tags ming

1.DataGridView Data Binding

1 namespaceWindowsFormsApplication12 {3      Public Partial classForm1:form4     {5         PrivateList<student> _students =NewList<student>();6 7          PublicForm1 ()8         {9 InitializeComponent ();Ten  One_students. ADD (NewStudent () {Name ="Huang Yong", age = -, School ="Harbin University of Commerce" }); A  -_students. ADD (NewStudent () {Name ="Ming He", age = -, School ="Hunan Polytechnic University" }); -  the_students. ADD (NewStudent () {Name ="Tommy", age = +, School ="University of Hong Kong" }); -  +             varBindingList =NewBindinglist<student>(_students); -  atDatagridview1.datasource =bindingList; -  -         } -  -         Private voidButton1_Click (Objectsender, EventArgs e) -         { in             varStudent = _students. FirstOrDefault (item = Item). Name.equals ("Ming He")); -  to             if(Student! =NULL) +             { -                 //dynamically refreshes the UI theStudent. Name =" -"; *             } $         }Panax Notoginseng     } -  the      Public classstudent:inotifypropertychanged +     { A          Public EventPropertyChangedEventHandler propertychanged; the  +         PrivateString _name; -         PrivateInt32 _age; $         PrivateString _school; $  -          PublicString Name -         { the             Get -             {Wuyi                 return_name; the             } -             Set Wu             { -                 if(Value! =_name) About                 { $_name =value; -                      This. Notifypropertychanged ("Name"); -                 } -             } A         } +  the          PublicInt32 Age -         { $             Get the             { the                 return_age; the             } the             Set -             { in                 if(Value! =_age) the                 { the_age =value; About                      This. Notifypropertychanged (" Age"); the                 } the             } the         } +  -          PublicString School the         {Bayi             Get the             { the                 return_school; -             } -             Set the             { the                 if(Value! =_school) the                 { the_school =value; -                      This. Notifypropertychanged ("School"); the                 } the             } the         }94  the         Private voidNotifypropertychanged (stringname) the         { the             if(PropertyChanged! =NULL)98             { AboutPropertyChanged ( This,NewPropertyChangedEventArgs (name)); -             }101         }102     }103}

Winform Data Binding

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.