Winform 数据绑定
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 数据绑定的更多相关文章
- 【转】详解Data Binding 通过几个简单示例深入了解WinForm数据绑定特性
原文地址:http://www.cnblogs.com/lichence/archive/2012/02/17/2356001.html
- DataGridView控件
DataGridView控件 DataGridView是用于Windows Froms 2.0的新网格控件.它可以取代先前版本中DataGrid控件,它易于使用并高度可定制,支持很多我们的用户需要的特 ...
- DataGridView控件-[引用]
DataGridView控件 DataGridView是用于Windows Froms 2.0的新网格控件.它可以取代先前版本中DataGrid控件,它易于使用并高度可定制,支持很多我们的用户需要的特 ...
- c#dataGridView 知识
一.单元格内容的操作 // 取得当前单元格内容 Console.WriteLine(DataGridView1.CurrentCell.Value); // 取得当前单元格的列 Index Conso ...
- DataGridView控件使用大全说明-各种常用操作与高级操作
DataGridView控件 DataGridView是用于Windows Froms 2.0的新网格控件.它可以取代先前版本中DataGrid控件,它易于使用并高度可定制,支持很多我们的用户需要的特 ...
- DataGridView控件使用大全
转自:http://www.cnblogs.com/xiaofengfeng/archive/2011/04/16/2018504.html DataGridView控件 DataGridView是用 ...
- C#实现WinForm DataGridView控件支持叠加数据绑定
我们都知道WinForm DataGridView控件支持数据绑定,使用方法很简单,只需将DataSource属性指定到相应的数据源即可,但需注意数据源必须支持IListSource类型,这里说的是支 ...
- C# WinForm 中ComboBox数据绑定的问题 (转)
来自:http://blog.sina.com.cn/s/blog_5fb9e26301013wga.html C# WinForm 中ComboBox数据绑定的问题 怎样让WinForm中的Comb ...
- WinForm控件复杂数据绑定常用数据源(对Combobox,DataGridView等控件DataSource赋值的多种方法)
开始以前,先认识一下WinForm控件数据绑定的两种形式,简单数据绑定和复杂数据绑定. 1) 简单数据绑定 简单的数据绑定是将用户控件的某一个属性绑定至某一个类型实例上的某一属性.采用如下形式进行绑定 ...
随机推荐
- Discuz被挂马 快照被劫持跳转该如何处理 如何修复discuz漏洞
Discuz 3.4是目前discuz论坛的最新版本,也是继X3.2.X3.3来,最稳定的社区论坛系统.目前官方已经停止对老版本的补丁更新与升级,直接在X3.4上更新了,最近我们SINE安全在对其安全 ...
- java中reader和writer部分的笔记
输入和输出流:获取流对象从文件中获取InputStream in = Files.newInputStream(path);OutputStream out = Files.newOutputStre ...
- Java基础—ArrayList源码浅析
注:以下源码均为JDK8的源码 一. 核心属性 基本属性如下: 核心的属性其实是红框中的两个: //从注释也容易看出,一个是集合元素,一个是集合长度(注意是逻辑长度,即元素的个数,而非数组长度) 其中 ...
- Windows下的SysWow64和System32
64位的Windows并不是简单地把所有东西都编译成64位就万事大吉的.关于64位的CPU应该做成什么样子,Intel和AMD曾有各自的打算.AMD的回答直接了当:新的64位处理器,应该能在提高更高处 ...
- Chrome模拟平板调试
1. 按F12,打开开发者工具,右上角,点击红圈中的标志.然后在弹出的面板中点击'Emulation'. 2. 会看到左侧的四个选项卡 Device 设备.Screen 屏幕.User Agent ...
- 笔记本ubuntu安装wifi驱动(未完成)
1. 用联想E440,Ubuntu14.04,安装完之后,没有检查到wifi的驱动,所以需要安装.
- MySQL - 问题集 - Access denied; you need the SUPER privilege for
当执行存储过程相关操作时,如果出现该错误,则往下看. 打开存储过程,会发现“CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost`”. 由于DEFI ...
- kaggle入门--泰坦尼克号之灾(手把手教你)
作者:炼己者 具体操作请看这里-- https://www.jianshu.com/p/e79a8c41cb1a 大家也可以看PDF版,用jupyter notebook写的,视觉效果上感觉会更棒 链 ...
- hdu1181变形课(floyd)
变形课 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submis ...
- 41. Maximum Subarray
Description Given an array of integers, find a contiguous subarray which has the largest sum. The su ...