构建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 ...
随机推荐
- Hbase数据导入导出
平时用于从生产环境hbase到导出数据到测试环境. 导入数据: import java.io.BufferedReader; import java.io.File; import java.io.F ...
- POJ 3468 A Simple Problem with Integers(线段树 成段增减+区间求和)
A Simple Problem with Integers [题目链接]A Simple Problem with Integers [题目类型]线段树 成段增减+区间求和 &题解: 线段树 ...
- Struts2中Action由自己与由Spring管理的区别
struts2单独使用时action由struts2自己负责创建:与spring集成时,action实例由spring负责创建. 这导致在两种情况下struts.xml配置文件的略微差异. 假如: ...
- createjs easal.js制作了一个很简单的链路图
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- WPF控件 RichTextBox查找定位匹配字符
private void Search_Click(object sender, RoutedEventArgs e)//查询定位文本 { List<TextRange> textRang ...
- CentOS 网卡配置bond4(LACP)
交换机开启LACP,配置聚合. 网卡eno1, eno2, eno3.eno1为管理口,eno2和eno3绑定,配置bond4. 配置eno2: vim /etc/sysconfig/network- ...
- Python基础(二)之list
列表:用[]表示 常用方法: list.append,list.insert,list.remove,list.pop,list.count,list.sort,list.reverse,list.i ...
- JS滑动
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 清空SQL Server数据库中所有表数据的方法(转)
清空SQL Server数据库中所有表数据的方法 其实删除数据库中数据的方法并不复杂,为什么我还要多此一举呢,一是我这里介绍的是删除数据库的所有数据,因为数据之间可能形成相互约束关系,删除操作可能陷入 ...
- CRM Setstate plugin
pre 事件 throw new InvalidPluginExecutionException("pre-StateCode:" + StateCode + ",pre ...