WinForm development-Interface controls to entities, entity to interface controls automatically bound

Source: Internet
Author: User

In WinForm development, are we assigning values to each control for the data that binds the interface control? Is it the assignment of each control to the entity when you save the changes? A lot of fields, that's a nightmare. Is there a convenient way to map it directly, like in the Web? Now not so cumbersome, in the Rdiframework.net development framework of the WinForm part of the new interface control to the entity, the entity to the interface control automatically binding, a word is done, very convenient. The main is to refer to the "RDIFramework.WinForm.Utilities.dll" DLL file, and then call the following two methods:

1. Automatic mapping of entity-to-Interface controls:formbinding.bindobjecttocontrols (testentity, this);

2. Automatic mapping of interface controls to entities:Formbinding.bindcontrolstoobject (testentity, this);

The effect is as follows:

The following shows the entire code of the above test interface for your reference:

Using System;namespace rdiframework.test{using Rdiframework.utilities;    Using RDIFramework.WinForm.Utilities;        Public partial class Frmformbindingtest:baseform {exampleentity testentity = new exampleentity ();        Public Frmformbindingtest () {InitializeComponent (); } public override void Formonload () {base.            Formonload ();            Bindcategory ();        Formbinding.bindobjecttocontrols (testentity, this); } private void Bindcategory () {basepagelogic.bindcategory (base.            UserInfo, ProductCategory, "ProductCategory"); Basepagelogic.bindcategory (base.        UserInfo, ComboBox1, "Gender"); private void Btnentitytocontrol_click (object sender, EventArgs e) {Formbinding.bindobjecttocon        Trols (testentity, this); private void Btncontroltoentity_click (object sender, EventArgs e) {Formbinding.bindcontrolstoo Bject (TestenTity, this);        This.richTextBox1.Text = Testentity.tostring (); private void btnClose_Click (object sender, EventArgs e) {this.        Close ();        }} public class Exampleentity {public string Text1 {get; set;}        public string Text2 {get; set;}        public string ComboBox1 {get; set;}        public string ProductCategory {get; set;} Public DateTime?        DateTime1 {get; set;} Public decimal?        MaskText1 {get; set;} public int?        Int1 {get; set;}        public int Enabled1 {get; set;}            Public exampleentity () {Text1 = "ValueText1";            TEXT2 = "ValueText2";            DateTime1 = Businesslogic.converttodatetime (DateTime.Now.AddDays (-2));            MaskText1 = Businesslogic.converttonullabledecimal (12345.12);            Int1 = 124;            Enabled1 = 1;            ComboBox1 = "male";        ProductCategory = "other";        } public override string ToString (){String returnvalue = "Text1:" + Text1 + "\ r Text2:" + Text2;            returnvalue + = "\ r comboBox1:" + comboBox1 + "\ r Int1:" + int1.tostring () + "\ r DateTime1:" + datetime1.tostring (); returnvalue + = "\ r productcategory:" + productcategory + "\ r MaskText1:" + masktext1.tostring () + "\ r Enabled1:" +            Enabled1.tostring ();        return returnvalue.tostring (); }    }}

  

List of related articles:

Rdiframework.net-based on. NET rapid Information System development Framework-Series catalogue

For a few years, thanks to the supporters and users of the rdiframework.net framework, you can find out more at the address below.

rdiframework.net official website:http://www.rdiframework.net/

rdiframework.net Official blog:http://blog.rdiframework.net/

At the same time need to be explained, all the technical articles in the future to the official website as the subject, welcome to our collection!

rdiframework.net Framework by the professional team for a long time to build, has been updated, has been upgrading, please rest assured that use!

Welcome to Rdiframework.net Framework Official public (No.:rdiframework-net), keep abreast of the latest developments.

Scan QR code for immediate attention

WinForm development-Interface controls to entities, entity to interface controls automatically bound

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.