构建winform控件数据缓存器
DataBindingHelper使用手册
1.引用Rabbit.Core.dll文件
也就是我自己编写的功能库Rabbit.Core.dll呵呵。
Rabbi.Core.DLL密码:dgqv xml注释 密码:uxxk
2.引用命名空间
using Rabbit.Core;
3.示例demo
using System;
using System.Windows.Forms;
using Rabbit.UI.DataBindingHelper;
using System.Collections.Generic;
using Rabbit.Core;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
#region 共有变量
List<FieldBindingContent> fieldList = new List<FieldBindingContent>();
#endregion public Form1()
{
InitializeComponent(); } FieldBindingContent fbc;
private void Form1_Load(object sender, EventArgs e)
{
List<a> aas = new List<a>();
aas.Add(new a() { ID = "", dispalyvalue = "男" });
aas.Add(new a() { ID = "", dispalyvalue = "女" });
comboBox1.DataSource = aas;
comboBox1.ValueMember = "ID";
comboBox1.DisplayMember = "dispalyvalue";
GetControlList();
}
//将需要操作的控件进行绑定
public void GetControlList()
{
fieldList.Add(new FieldBindingContent("name", "文本框", textBox1, "Text", ""));
fieldList.Add(new FieldBindingContent("remark", "富文本框", richTextBox1, "Text", ""));
fieldList.Add(new FieldBindingContent("sex", "", comboBox1, "SelectedValue", ""));
fieldList.Add(new FieldBindingContent("flag", "true", checkBox1, "Checked", false)); }
private void button1_Click(object sender, EventArgs e)
{
foreach (FieldBindingContent item in fieldList)
{
if (item.FieldName != "sex") {
continue;
}
label5.Text = item.FieldValue.ToString();
}
} private void button2_Click(object sender, EventArgs e)
{
foreach (FieldBindingContent item in fieldList)
{ item.SetDefaultProperty();
}
} private void button3_Click(object sender, EventArgs e)
{
foreach (FieldBindingContent item in fieldList)
{
if (item.FieldName == "remark")
item.SetProperty("hello!");
}
} private void button4_Click(object sender, EventArgs e)
{
foreach (FieldBindingContent item in fieldList)
{
if (item.FieldName == "flag")
label6.Text = item.GetProperty().ToString();
}
} private void label5_Click(object sender, EventArgs e)
{ } }
public class a
{
public string ID { get; set; }
public string dispalyvalue { get; set; }
}
}
4.演示效果

5.主要操作方法说明
I.public FieldBindingContent(string fieldName,
object fieldValue,
Control bindingControl,
string bindingProperty,
object defaultValue
)
主要是通过FieldBindingContent类的构造函数来实现控件于该类(作为数据源)的绑定
参数说明:
/// <summary>
/// 绑定控件属性
/// </summary>
/// <param name="fieldName">字段名绑定在控件的tag值上,以便搜索该控件</param>
/// <param name="fieldValue">字段值,绑定控件的指定属性值</param>
/// <param name="bindingControl">控件</param>
/// <param name="bindingProperty">控件属性值</param>
/// <param name="defaultValue">指定控件默认值</param>
示例:看上面的代码,你懂的
II. public object GetProperty()
参数说明:
/// <summary>
/// 获取当前控件绑定的属性值
/// </summary>
/// <returns>返回属性值</returns>
示例:看上面代码,你懂的
III. public void SetProperty(object Value);
参数说明:
/// <summary>
/// 设置绑定的控件的属性值
/// </summary>
/// <param name="Value">待设置的数据</param>
示例:看上面代码,你懂的
IV. public void SetDefaultProperty()
参数说明:
/// <summary>
/// 控件属性恢复初始值
/// </summary>
示例:看上面代码,你懂的
V.主要属性展示
public bool AllowNull { get; set; }
public Control BindingControl { get; set; }//控件
public string BindingProperty { get; set; }//控件的属性名
public object DefaultValue { get; set; }//控件的默认值
public object FieldValue { get; set; }//绑定的属性值
public string FieldName { get; set; }//绑定的字段名
6.关于
本人qq:739462304。找自己一起交流技术。我相信交流才能快速进步.另外如果觉得用起来不错,希望给个赞
构建winform控件数据缓存器的更多相关文章
- iOS开发UI篇—实现UItableview控件数据刷新
iOS开发UI篇—实现UItableview控件数据刷新 一.项目文件结构和plist文件 二.实现效果 1.说明:这是一个英雄展示界面,点击选中行,可以修改改行英雄的名称(完成数据刷新的操作). 运 ...
- C# 扩展方法奇思妙用高级篇六:WinForm 控件选择器
在Web开发中,jQuery提供了功能异常强大的$选择器来帮助我们获取页面上的对象.但在WinForm中,.Net似乎没有这样一个使用起来比较方便的选择器.好在我们有扩展方法,可以很方便的打造一个. ...
- .Net WinForm 控件键盘消息处理剖析
在WinForm控件上我们可以看到很多关于键盘消息处理的方法,比如OnKeyDown, OnKeyPress, ProcessCmdKey, ProcessDialogKey,IsInputKey等等 ...
- Google guava cache源码解析1--构建缓存器(3)
此文已由作者赵计刚授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 下面介绍在LocalCache(CacheBuilder, CacheLoader)中调用的一些方法: Ca ...
- Google guava cache源码解析1--构建缓存器(1)
此文已由作者赵计刚授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 1.guava cache 当下最常用最简单的本地缓存 线程安全的本地缓存 类似于ConcurrentHas ...
- WinForm 控件键盘消息处理剖析(转)
一直想整理键盘事件的调用顺序,刚好看见园子里的这篇文章,写的不错,就转载了:http://www.cnblogs.com/tedzhao/archive/2010/09/07/1820557.html ...
- 第二章 Google guava cache源码解析1--构建缓存器
1.guava cache 当下最常用最简单的本地缓存 线程安全的本地缓存 类似于ConcurrentHashMap(或者说成就是一个ConcurrentHashMap,只是在其上多添加了一些功能) ...
- 浅谈Winform控件开发(一):使用GDI+美化基础窗口
写在前面: 本系列随笔将作为我对于winform控件开发的心得总结,方便对一些读者在GDI+.winform等技术方面进行一个入门级的讲解,抛砖引玉. 别问为什么不用WPF,为什么不用QT.问就是懒, ...
- [LeetCode] LRU Cache 最近最少使用页面置换缓存器
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the fol ...
随机推荐
- 现代DOJO(翻译)
http://dojotoolkit.org/documentation/tutorials/1.10/modern_dojo/index.html 你可能已经不用doio一段时间了,或者你一直想保持 ...
- Html5上传后有所见图片效果前端代码实现
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- lsyncd 实时同步
1. 几大实时同步工具比较 1.1 inotify + rsync 最近一直在寻求生产服务服务器上的同步替代方案,原先使用的是inotify + rsync,但随着文件数量的增大到100W+,目录下的 ...
- 【解决】putty使用从AWS下载的private key登录失败
在AWS启动一个实例时如果创建并下载了一个KeyPair的私钥(*.pem),则可以此私钥作为Credentials通过putty远程登录到这个实例系统.但在实际操作中,用putty登录时会提示如下错 ...
- U-Boot GOT表分析和u-boot.lds解读
转自:http://blog.sina.com.cn/s/blog_70dd16910100zab6.html u-boot-2010.09/arch/powerpc/cpu/mpc86xx/star ...
- 使用U盘安装win7系统
--------------------------------------------------- 步骤1:制作可启动U盘(如果已经有可启动U盘则直接跳到步骤2) 1.下载系统镜像,请百度搜索“w ...
- Esfog_UnityShader教程_溶解效果Dissolve
溶解效果在游戏中是很常见的,比如在一些神话或者魔法世界中,一些NPC角色在剧情需要时候会身体会渐渐的消失掉.甚至有一些更炫的,比如用火焰喷射器把目标燃尽.这些都可以用到溶解效果.这篇文章主要是讲解一下 ...
- js访问xml
从w3school中获取代码 <html> <head> <script type="text/javascript"> var xmlhttp ...
- CentOS 6.5安装Oracle 11.2.0.4------CentOS 6.5安装
规划: IP:192.168.213.199 mask: 255.255.255.0 gateway:192.168.213.1 DNS1:202.101.172.35 磁盘分区: 磁盘总大小:25G ...
- LPC2478_调试心得(转)
1.在调试“E:\htwang\smart2200v201\ARM嵌入式系统实验教程(二)\开发板出厂编程程序\液晶显示程序\LCM_Disp”的程序时,想使用外部RAM进行仿真调试,在将ADS1.2 ...