构建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 ...
随机推荐
- [经验交流] Kubernetes Nginx Ingress 安装与使用
Ingress 介绍 Kubernetes 上部署的微服务运行在它的私有网络中, 通过Pod实例的hostPort或Service实例的NodePort可以暴露到主机端口上,便于用户访问.但这样的方法 ...
- OAF_文件系列7_实现OAF处理Excel的JXL包介绍(概念)
20150714 Created By BaoXinjian
- SpringMVC中利用@InitBinder来对页面数据进行解析绑定
同步发布:http://www.yuanrengu.com/index.php/springmvc-user-initbinder.html 在使用SpingMVC框架的项目中,经常会遇到页面某些数据 ...
- 同时使用Junit4的@Parameterized参数化测试和Spring容器
转载:http://www.jianshu.com/p/d191fe54915f 整合Spring容器 @SpringApplicationConfiguration(classes = Applic ...
- iOS 8潜在的取证问题
Apple于今天正式发布了iOS 8推送升级 大概琢磨了一下: 1. 可以确定,iOS 7中存在的File relay等所谓后门服务已经被修正,目前Oxygen和我们采用这种服务提取的功能将不再适用于 ...
- 转ASP.NET1.1请求队列限制
在教务web的选课的维护中,经常面临asp.net1.1报错,在客户端跳转到用户自定义页面,在服务器端可以看到如下错误信息: “/”应用程序中的服务器错误. 服务器太忙 说明: 执行当前 Web 请求 ...
- Erlang 参考资料
Erlang 官方文档 Distributed Erlang Erlang 教程中文版 %设定模块名 -module(tut17). %导出相关函数 -export([start_ping/1, st ...
- [python实现设计模式]-5.迭代器模式-一起撸串嗨皮啦
迭代器模式是一个我们经常使用但是出境不高的模式. 为啥捏?因为大部分的语言都帮我们实现了细节,我们不许关注他的实现就能用的很嗨皮了. 不管怎样.这也是个非常常用的模式. 俗话说得好,这个世界上没有事情 ...
- ListFragment创建及其生命周期
相同的ListFragment 带有一个无参构造 一个有参构造 在该Fragment所依附的Activity视图创建时被实例化一次 方法周期分别为1.无参构造2.onInflate3.onAttach ...
- 冒泡排序,sql分页语句
对数组中的数字进行排序 public int[] PopSmall(int[] IntArray) { ; ; i < IntArray.Length - ; i++) { ; j < I ...