1.DataGridView数据绑定

 namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private List<Student> _students = new List<Student>(); public Form1()
{
InitializeComponent(); _students.Add(new Student() { Name = "黄勇", Age = , School = "哈尔滨商业大学" }); _students.Add(new Student() { Name = "何明", Age = , School = "湖南理工大学" }); _students.Add(new Student() { Name = "Tommy", Age = , School = "香港大学" }); var bindingList = new BindingList<Student>(_students); dataGridView1.DataSource = bindingList; } private void button1_Click(object sender, EventArgs e)
{
var student = _students.FirstOrDefault(item => item.Name.Equals("何明")); if (student != null)
{
//可动态刷新UI
student.Name = "";
}
}
} public class Student : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged; private String _name;
private Int32 _age;
private String _school; public String Name
{
get
{
return _name;
}
set
{
if (value != _name)
{
_name = value;
this.NotifyPropertyChanged("Name");
}
}
} public Int32 Age
{
get
{
return _age;
}
set
{
if (value != _age)
{
_age = value;
this.NotifyPropertyChanged("Age");
}
}
} public String School
{
get
{
return _school;
}
set
{
if (value != _school)
{
_school = value;
this.NotifyPropertyChanged("School");
}
}
} private void NotifyPropertyChanged(string name)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
}
}

Winform 数据绑定的更多相关文章

  1. 【转】详解Data Binding 通过几个简单示例深入了解WinForm数据绑定特性

    原文地址:http://www.cnblogs.com/lichence/archive/2012/02/17/2356001.html

  2. DataGridView控件

    DataGridView控件 DataGridView是用于Windows Froms 2.0的新网格控件.它可以取代先前版本中DataGrid控件,它易于使用并高度可定制,支持很多我们的用户需要的特 ...

  3. DataGridView控件-[引用]

    DataGridView控件 DataGridView是用于Windows Froms 2.0的新网格控件.它可以取代先前版本中DataGrid控件,它易于使用并高度可定制,支持很多我们的用户需要的特 ...

  4. c#dataGridView 知识

    一.单元格内容的操作 // 取得当前单元格内容 Console.WriteLine(DataGridView1.CurrentCell.Value); // 取得当前单元格的列 Index Conso ...

  5. DataGridView控件使用大全说明-各种常用操作与高级操作

    DataGridView控件 DataGridView是用于Windows Froms 2.0的新网格控件.它可以取代先前版本中DataGrid控件,它易于使用并高度可定制,支持很多我们的用户需要的特 ...

  6. DataGridView控件使用大全

    转自:http://www.cnblogs.com/xiaofengfeng/archive/2011/04/16/2018504.html DataGridView控件 DataGridView是用 ...

  7. C#实现WinForm DataGridView控件支持叠加数据绑定

    我们都知道WinForm DataGridView控件支持数据绑定,使用方法很简单,只需将DataSource属性指定到相应的数据源即可,但需注意数据源必须支持IListSource类型,这里说的是支 ...

  8. C# WinForm 中ComboBox数据绑定的问题 (转)

    来自:http://blog.sina.com.cn/s/blog_5fb9e26301013wga.html C# WinForm 中ComboBox数据绑定的问题 怎样让WinForm中的Comb ...

  9. WinForm控件复杂数据绑定常用数据源(对Combobox,DataGridView等控件DataSource赋值的多种方法)

    开始以前,先认识一下WinForm控件数据绑定的两种形式,简单数据绑定和复杂数据绑定. 1) 简单数据绑定 简单的数据绑定是将用户控件的某一个属性绑定至某一个类型实例上的某一属性.采用如下形式进行绑定 ...

随机推荐

  1. seleniun 爬取淘宝网

    import re from selenium import webdriver from selenium.common.exceptions import TimeoutException fro ...

  2. 『Python基础-1 』 编程语言Python的基础背景知识

    #『Python基础-1 』 编程语言Python的基础背景知识 目录: 1.编程语言 1.1 什么是编程语言 1.2 编程语言的种类 1.3 常见的编程语言 1.4 编译型语言和解释型语言的对比 2 ...

  3. git小技巧之分支、关联远程仓库、回滚、解决.gitignore不生效等

    1.分支管理 新建并切换分支:git checkout -b <name>新建本地分支并关联到远程分支git checkout -b myRelease origin/Release合并某 ...

  4. 批量改变图片的尺寸大小 python opencv

    我目标文件夹下有一大批图片,我要把它转变为指定尺寸大小的图片,用pthon和opencv实现的. 以上为原图片. import cv2 import os # 按指定图像大小调整尺寸 def resi ...

  5. [Real World Haskell翻译]第22章 扩展示例:Web客户端编程

    第22章 扩展示例:Web客户端编程 至此,您已经看到了如何与数据库交互,解析一些数据,以及处理错误.现在让我们更进了一步,引入Web客户端库的组合. 在本章,我们将开发一个真正的应用程序:一个播客下 ...

  6. sql中的几种连接类型

    一.连接类型简介 在sql中单表查询的几率相对来说比较少,随着数据库的日益复杂,多表关联的情况越来越多,在多表关联的情况下存在多种关联的类型, 1.自关联(join或inner join) 2.左外关 ...

  7. python import vs from import

    https://stackoverflow.com/questions/9439480/from-import-vs-import

  8. PS 拉伸大长腿

    1.打开一个图片工具栏--图像--画布大小 2.选择矩形选框工具--框住要拉升退的位置--然后在按Ctrl+T,进行拉伸即可

  9. Python3开启Http服务

    在CMD命令行输入D: 切换到D盘, 然后输入 python -m http.server 8000 开启HTTP服务: 在浏览器地址栏输入 http://localhost:8000/

  10. 【WXS全局对象】consloe

    consloe对象 方法: 原型:console.log( [String] ) 说明:用于在 console 窗口输出信息,一般用于程序调试使用示例: console.log支持arguments类 ...