1 Star 0 Fork 1

方舟 / AutoControlMapper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

#AutoControlMapper 一个通过Contorl.Tag属性,将变量值与控件自动映射的工具类,使用非常简单。


###使用示例

Form frm = new Control();
AutoControlMapper _acm = new AutoControlMapper();//实例化对象
_acm.RegisterVariableObject(null, obj);//注册变量
_acm.UpdateToUI(frm );//更新到控件
_acm.UpdateFromUI(frm );//更新到变量

###具体步骤 我们假设有一个窗体控件

Form frm_main;
|-TextBox tb_name;
|-TextBox tb_age;

和一个待显示的变量

Person person;
|-string Name;
|-string Age;

  1. 修改控件的Tag属性
tb_name.Tag= "Name";//指向person.Name
tb_age.Tag= "Age";//指向person.Age

2.编辑代码

//更新变量到控件
AutoControlMapper _acm = new AutoControlMapper();//实例化对象
_acm.RegisterVariableObject(null, person);//注册 person
_acm.UpdateToUI(frm_main);//导入frm_main,他会将变量的值更新到frm_main下面的所有控件(不包括它自身)
//更新控件到变量
AutoControlMapper _acm = new AutoControlMapper();//实例化对象
_acm.RegisterVariableObject(null, person);//注册 person
_acm.UpdateFromUI(frm_main);//导入frm_main,他会更新frm_main下面的所有控件的值到已注册的变量(不包括它自身)

###注意事项 1.这个版本暂时只支持同一个属性的单次注册,如果同一个属性,多次注册,则会报错。
2.当变量的值改变时,需要重新注册,控件的值不会自动更新;所以推荐每次更新空间的时候,都重新注册变量。

The MIT License (MIT) Copyright (c) 2017 chxaitz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

一个通过Contorl.Tag属性,将变量值自动映射到控件的工具类,使用非常简单。 展开 收起
C#
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/chenx_ark/AutoControlMapper.git
git@gitee.com:chenx_ark/AutoControlMapper.git
chenx_ark
AutoControlMapper
AutoControlMapper
master

搜索帮助