Click here to Skip to main content
15,896,201 members
Articles / Desktop Programming / Windows Forms

Asynchronous data loading and data binding with Windows Forms

Rate me:
Please Sign up or sign in to vote.
4.29/5 (6 votes)
15 Dec 2008CPOL3 min read 48.5K   1.8K   55  
This article introduces a reusable library that contains two utility components for data binding and asynchronous data loading.
using System.Windows.Forms;

partial class frmUsers : System.Windows.Forms.Form
{

    public frmUsers()
    {
        InitializeComponent();
    }
    //Form overrides dispose to clean up the component list.
	[System.Diagnostics.DebuggerNonUserCode()]
	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	//Required by the Windows Form Designer
	private System.ComponentModel.IContainer components;

	//NOTE: The following procedure is required by the Windows Form Designer
	//It can be modified using the Windows Form Designer.  
	//Do not modify it using the code editor.
	[System.Diagnostics.DebuggerStepThrough()]
	private void InitializeComponent()
	{
        this.grdUsers = new System.Windows.Forms.DataGridView();
        this.Label3 = new System.Windows.Forms.Label();
        this.Label2 = new System.Windows.Forms.Label();
        this.Label1 = new System.Windows.Forms.Label();
        this.txtEmail = new System.Windows.Forms.TextBox();
        this.txtPassword = new System.Windows.Forms.TextBox();
        this.txtUsername = new System.Windows.Forms.TextBox();
        this.userDataBinder = new DataBinder();
        ((System.ComponentModel.ISupportInitialize)(this.grdUsers)).BeginInit();
        this.SuspendLayout();
        // 
        // grdUsers
        // 
        this.grdUsers.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
        this.grdUsers.Location = new System.Drawing.Point(12, 110);
        this.grdUsers.Name = "grdUsers";
        this.grdUsers.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
        this.grdUsers.Size = new System.Drawing.Size(646, 163);
        this.grdUsers.TabIndex = 15;
        // 
        // Label3
        // 
        this.Label3.AutoSize = true;
        this.Label3.Location = new System.Drawing.Point(62, 75);
        this.Label3.Name = "Label3";
        this.Label3.Size = new System.Drawing.Size(38, 13);
        this.Label3.TabIndex = 14;
        this.Label3.Text = "Email :";
        // 
        // Label2
        // 
        this.Label2.AutoSize = true;
        this.Label2.Location = new System.Drawing.Point(374, 53);
        this.Label2.Name = "Label2";
        this.Label2.Size = new System.Drawing.Size(60, 13);
        this.Label2.TabIndex = 13;
        this.Label2.Text = "Password :";
        // 
        // Label1
        // 
        this.Label1.AutoSize = true;
        this.Label1.Location = new System.Drawing.Point(62, 51);
        this.Label1.Name = "Label1";
        this.Label1.Size = new System.Drawing.Size(62, 13);
        this.Label1.TabIndex = 12;
        this.Label1.Text = "Username :";
        // 
        // txtEmail
        // 
        this.txtEmail.Location = new System.Drawing.Point(128, 75);
        this.txtEmail.Name = "txtEmail";
        this.txtEmail.Size = new System.Drawing.Size(165, 21);
        this.txtEmail.TabIndex = 11;
        // 
        // txtPassword
        // 
        this.txtPassword.Location = new System.Drawing.Point(442, 49);
        this.txtPassword.Name = "txtPassword";
        this.txtPassword.Size = new System.Drawing.Size(165, 21);
        this.txtPassword.TabIndex = 10;
        // 
        // txtUsername
        // 
        this.txtUsername.Location = new System.Drawing.Point(128, 49);
        this.txtUsername.Name = "txtUsername";
        this.txtUsername.Size = new System.Drawing.Size(165, 21);
        this.txtUsername.TabIndex = 9;
        // 
        // userDataBinder
        // 
        this.userDataBinder.DAOObject = null;
        this.userDataBinder.Dock = System.Windows.Forms.DockStyle.Top;
        this.userDataBinder.EntityType = null;
        this.userDataBinder.Location = new System.Drawing.Point(0, 0);
        this.userDataBinder.Name = "userDataBinder";
        this.userDataBinder.RefreshRequired = false;
        this.userDataBinder.ShowNotification = true;
        this.userDataBinder.Size = new System.Drawing.Size(670, 37);
        this.userDataBinder.TabIndex = 8;
        
        // 
        // frmUsers
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(670, 280);
        this.Controls.Add(this.grdUsers);
        this.Controls.Add(this.Label3);
        this.Controls.Add(this.Label2);
        this.Controls.Add(this.Label1);
        this.Controls.Add(this.txtEmail);
        this.Controls.Add(this.txtPassword);
        this.Controls.Add(this.txtUsername);
        this.Controls.Add(this.userDataBinder);
        this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.Name = "frmUsers";
        this.Text = "Users";
        this.Load += new System.EventHandler(this.frmUsers_Load);
        ((System.ComponentModel.ISupportInitialize)(this.grdUsers)).EndInit();
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    internal DataGridView grdUsers;
    internal Label Label3;
    internal Label Label2;
    internal Label Label1;
    internal TextBox txtEmail;
    internal TextBox txtPassword;
    internal TextBox txtUsername;
    internal DataBinder userDataBinder;

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Canada Canada
Ashutosh is an avid programmer, who “lives to code”. One can always find him busy seeking challenging programming assignments on various complex problems ranging from Data management, Classification, Optimization, Security, Network analysis, Distributed computing.

He started his programming stint with “C”; he has also worked on C++, Visual Basic, JAVA, Perl, FoxPro, PASCAL, Shell Scripting, and Perl. Currently, he is proficient and working on C#.

His area of interest includes Distributed Computing, Analytic and Business Intelligence, Large Enterprise System Architectures, Enterprise Content Management.

He is an advocate of Open source and likes to share solutions with open source communities like
1.Stack Overflow
2. nHibernate
.

Award's :
Prize winner in Competition "Best article of May 2008"

Articles :
Click to see my CodeProject Articles

Blog :
Share a solution | Explore the .NET world

Link'd :


His Favorite(s) :
nHibernate - The best ORM.
nHibernate Contributed Tools

Comments and Discussions