Data Binding: StringCollection : DataBinding TextBox « GUI Windows Forms « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » GUI Windows Forms » DataBinding TextBox 
23.82.1.Data Binding: StringCollection
using System;
using System.Drawing;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Windows.Forms;

public class DataBoundStringCollection : System.Windows.Forms.Form
{
  private Button RightButton= new Button();
  private Button LeftButton= new Button();
  private TextBox textBox2 = new TextBox();
  private TextBox textBox1 = new TextBox();
  private Button DoneButton= new Button();

  private StringCollection sa=new StringCollection();

    public DataBoundStringCollection()
    {
    this.textBox2.Location = new Point(18416);

    this.RightButton.Location = new Point(19264);
    this.RightButton.Text = ">>";
    this.RightButton.Click += new EventHandler(this.RightButton_Click);

    this.textBox1.Location = new Point(816);

    this.DoneButton.Location = new Point(10464);
    this.DoneButton.Text = "Done";
    this.DoneButton.Click += new EventHandler(this.DoneButton_Click);

    this.LeftButton.Location = new Point(1664);
    this.LeftButton.Text = "<<";
    this.LeftButton.Click += new EventHandler(this.LeftButton_Click);

    this.AutoScaleBaseSize = new System.Drawing.Size(513);
    this.ClientSize = new System.Drawing.Size(294111);
    this.ControlBox = false;
    this.Controls.AddRange(new Control[] {
                  this.RightButton,
                  this.LeftButton,
                  this.textBox2,
                  this.textBox1,
                  this.DoneButton});
    this.FormBorderStyle = FormBorderStyle.FixedDialog;
    this.ShowInTaskbar = false;
    this.ResumeLayout(false);

    sa.Add("A");
    sa.Add("B");
    sa.Add("C");
    sa.Add("D");

    this.textBox1.DataBindings.Add("Text",sa,"");
    this.textBox2.DataBindings.Add("Text",sa,"");
    }
    public override void Dispose()
    {
        base.Dispose();
    }


  protected void RightButton_Click (object sender, System.EventArgs e)
  {
    this.BindingContext[sa].Position++;
  }

  protected void LeftButton_Click (object sender, System.EventArgs e)
  {
    this.BindingContext[sa].Position--;
  }

  protected void DoneButton_Click (object sender, System.EventArgs e)
  {
    Application.Exit();
  }

  public static void Main()
  {
    Application.Run(new DataBoundStringCollection());
  }
}
23.82.DataBinding TextBox
23.82.1.Data Binding: StringCollection
23.82.2.Data Entry With Binding
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.