构建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 ...
随机推荐
- SOAOffice和iWebOffice、NTKO的比较及其优势(转)
http://www.cnblogs.com/liping13599168/articles/1681465.html SOAOffice和iWebOffice.NTKO的比较及其优势 近年来,市场上 ...
- [SPI&I2C]I2C和SPI协议介绍
IIC vs SPI 现今,在低端数字通信应用领域,我们随处可见IIC (Inter-Integrated Circuit) 和 SPI (Serial Peripheral Interface)的身 ...
- Python使用struct处理二进制
有的时候需要用python处理二进制数据,比如,存取文件,socket操作时.这时候,可以使用python的struct模块来完成.可以用 struct来处理c语言中的结构体. struct模块中最重 ...
- Hololens开发笔记之Gesture手势识别(Manipulation手势控制物体平移)
Manipulation gesture:保持点击手势,在3D世界中绝对运动 当你想要全息图像1:1响应用户手部移动时,操纵手势能被用于移动.缩放或旋转全息图像.如此的一个用处是使得用户可以在世界中绘 ...
- Azure
ylbtech-Miscellaneos:Azure A,返回顶部 1, Windows Azure是微软基于云计算的操作系统,现在更名为“Microsoft Azure”,和Azure Servic ...
- selenium + phantomjs 爬取落网音乐
题记: 作为一个业余程序猿,最大的爱好就是电影和音乐了,听音乐当然要来点有档次的.落网的音乐的逼格有点高,一听听了10年.学习python一久了,于是想用python技术把落网的音乐爬下来随便听. 目 ...
- shell程序设计
1.shell脚本的基本概念: (1)Shell执行的是称为shell程序,这些程序通常被称为脚本. (2)Shell是一个用户和系统间接口的程序,它允许用户向操作系统输入需要执行的命令. (3)sh ...
- ORA-12519, ORA-00020异常产生原因及解决方案
近期在做项目的过程中,使用oracle时碰到了如下两个异常: ORA-12519, TNS:no appropriate service handler found: ORA-00020:maximu ...
- oracle kill session
kill session 是DBA经常碰到的事情之一.如果kill 掉了不该kill 的session,则具有破坏性,因此尽可能的避免这样的错误发生.同时也应当注意,如果kill 的session属于 ...
- [DFNews] EnCase 更新至 v7.10
有加密狗的可以注册接收邮件下载 暂时只有英文版 前几天讲课还说到,EnCase的Template倒是好,但是稍微改一下Case Template自带的Bookmark结构,那么Report就看不到了, ...