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控件数据缓存器的更多相关文章

  1. iOS开发UI篇—实现UItableview控件数据刷新

    iOS开发UI篇—实现UItableview控件数据刷新 一.项目文件结构和plist文件 二.实现效果 1.说明:这是一个英雄展示界面,点击选中行,可以修改改行英雄的名称(完成数据刷新的操作). 运 ...

  2. C# 扩展方法奇思妙用高级篇六:WinForm 控件选择器

    在Web开发中,jQuery提供了功能异常强大的$选择器来帮助我们获取页面上的对象.但在WinForm中,.Net似乎没有这样一个使用起来比较方便的选择器.好在我们有扩展方法,可以很方便的打造一个. ...

  3. .Net WinForm 控件键盘消息处理剖析

    在WinForm控件上我们可以看到很多关于键盘消息处理的方法,比如OnKeyDown, OnKeyPress, ProcessCmdKey, ProcessDialogKey,IsInputKey等等 ...

  4. Google guava cache源码解析1--构建缓存器(3)

    此文已由作者赵计刚授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 下面介绍在LocalCache(CacheBuilder, CacheLoader)中调用的一些方法: Ca ...

  5. Google guava cache源码解析1--构建缓存器(1)

    此文已由作者赵计刚授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 1.guava cache 当下最常用最简单的本地缓存 线程安全的本地缓存 类似于ConcurrentHas ...

  6. WinForm 控件键盘消息处理剖析(转)

    一直想整理键盘事件的调用顺序,刚好看见园子里的这篇文章,写的不错,就转载了:http://www.cnblogs.com/tedzhao/archive/2010/09/07/1820557.html ...

  7. 第二章 Google guava cache源码解析1--构建缓存器

    1.guava cache 当下最常用最简单的本地缓存 线程安全的本地缓存 类似于ConcurrentHashMap(或者说成就是一个ConcurrentHashMap,只是在其上多添加了一些功能) ...

  8. 浅谈Winform控件开发(一):使用GDI+美化基础窗口

    写在前面: 本系列随笔将作为我对于winform控件开发的心得总结,方便对一些读者在GDI+.winform等技术方面进行一个入门级的讲解,抛砖引玉. 别问为什么不用WPF,为什么不用QT.问就是懒, ...

  9. [LeetCode] LRU Cache 最近最少使用页面置换缓存器

    Design and implement a data structure for Least Recently Used (LRU) cache. It should support the fol ...

随机推荐

  1. 微信开发-ACCESS TOKEN 过期失效解决方案

    微信开发-ACCESS TOKEN 过期失效解决方案 起因:因为access_token的重要性,开发过微信的都知道,但是他有自己的生命周期,官方解释为:"有效期为7200秒",一 ...

  2. 也说php从mysql数据库通过服务器端json返回数据出现乱码问题

    我最近需要用js和json与mysql数据库做一个两级联动的下拉菜单,发现当从数据库中返回的是中文时客户端会出现乱码问题,经过在百度上查找终于找到了解决办法如下: while($row=$MySqlc ...

  3. Android WebView的Js对象注入漏洞解决方案

    http://blog.csdn.net/leehong2005/article/details/11808557/ webview调用以下文件,就可以打印sdcard 文件名 <!DOCTYP ...

  4. Window服务安装方式汇总

    一.制作bat文件 1)Install.bat: @echo 安装服务 %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\installutil AppS ...

  5. SpringMVC中利用@InitBinder来对页面数据进行解析绑定

    同步发布:http://www.yuanrengu.com/index.php/springmvc-user-initbinder.html 在使用SpingMVC框架的项目中,经常会遇到页面某些数据 ...

  6. 【转】C#多线程Lock使用

    一.Lock定义     lock 关键字可以用来确保代码块完成运行,而不会被其他线程中断.它可以把一段代码定义为互斥段(critical section),互斥段在一个时刻内只允许一个线程进入执行, ...

  7. U盘安装CentOS 7.0

    U盘安装CentOS 7.0 由于学习需要centos环境,so上网下载centos安装镜像,发现版本已经到7.0了,(╮(╯▽╰)╭,上次折腾还是6.4的版本呢,)花了一点时间下载下来按照装6.4的 ...

  8. iOS 在tableView上添加button导致按钮没有点击效果和不能滑动的 zhuang

    转载请注明出处. 今天在调试代码的时候,在tableviewcell上添加button,发现button快速点击的话,是看不出点击效果的,查找资料发现, ios7上UITableViewCell子层容 ...

  9. 从主机访问虚拟机上的Apache

    问题:VMWARE上安装的CentOS6.4,安装Apache,启动后,虚拟机上能访问,主机能ping通,但无法访问Apache. 原因:防火墙设置,配置iptables,开放apache的端口80

  10. ORA-12520:TNS:监听程序无法为请求的服务器类型找到可用的处理程序

    连接数太多 关掉没用的 plsql