Navigate the binded data using BindingManagerBase : BindingManagerBase « Database ADO.net « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Class Interface
3. Collections Data Structure
4. Components
5. Data Types
6. Database ADO.net
7. Design Patterns
8. Development Class
9. Event
10. File Stream
11. Generics
12. GUI Windows Form
13. Language Basics
14. LINQ
15. Network
16. Office
17. Reflection
18. Regular Expressions
19. Security
20. Services Event
21. Thread
22. Web Services
23. Windows
24. XML
25. XML LINQ
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / C Sharp » Database ADO.net » BindingManagerBaseScreenshots 
Navigate the binded data using BindingManagerBase

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

    public class Form1 : System.Windows.Forms.Form {
      private System.Windows.Forms.TextBox textBox1;
      private System.Windows.Forms.TextBox textBox2;
      private System.Windows.Forms.Button buttonBack;
      private System.Windows.Forms.Button buttonNext;
      private System.Data.DataSet dataSet1;
      private System.ComponentModel.Container components = null;

      private BindingManagerBase bMgr;

      public Form1() {
        InitializeComponent();
      }

      private void InitializeComponent() {
         this.textBox1 = new System.Windows.Forms.TextBox();
         this.textBox2 = new System.Windows.Forms.TextBox();
         this.buttonBack = new System.Windows.Forms.Button();
         this.buttonNext = new System.Windows.Forms.Button();
         this.dataSet1 = new System.Data.DataSet();
         ((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();
         this.SuspendLayout();

         this.textBox1.Location = new System.Drawing.Point(88);
         this.textBox1.Name = "textBox1";
         this.textBox1.Size = new System.Drawing.Size(16020);
         this.textBox1.TabIndex = 0;
         this.textBox1.Text = "textBox1";

         this.textBox2.Location = new System.Drawing.Point(840);
         this.textBox2.Name = "textBox2";
         this.textBox2.Size = new System.Drawing.Size(16020);
         this.textBox2.TabIndex = 1;
         this.textBox2.Text = "textBox2";

         this.buttonBack.Location = new System.Drawing.Point(2480);
         this.buttonBack.Name = "buttonBack";
         this.buttonBack.Size = new System.Drawing.Size(5623);
         this.buttonBack.TabIndex = 2;
         this.buttonBack.Text = "<< Back";
         this.buttonBack.Click += new System.EventHandler(this.buttonBack_Click);

         this.buttonNext.Location = new System.Drawing.Point(9680);
         this.buttonNext.Name = "buttonNext";
         this.buttonNext.Size = new System.Drawing.Size(5623);
         this.buttonNext.TabIndex = 3;
         this.buttonNext.Text = "Next>>";
         this.buttonNext.Click += new System.EventHandler(this.buttonNext_Click);

         this.dataSet1.DataSetName = "NewDataSet";
         this.dataSet1.Locale = new System.Globalization.CultureInfo("en-US");

         this.AutoScaleBaseSize = new System.Drawing.Size(513);
         this.ClientSize = new System.Drawing.Size(176108);
         this.Controls.Add(this.buttonNext);
         this.Controls.Add(this.buttonBack);
         this.Controls.Add(this.textBox2);
         this.Controls.Add(this.textBox1);
         this.Name = "Form1";
         this.Text = "Form1";
         this.Load += new System.EventHandler(this.Form1_Load);
         ((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();
         this.ResumeLayout(false);
      }

      static void Main() {
         Application.Run(new Form1());
      }

      private void Form1_Load(object sender, System.EventArgs e) {
         string connString = "server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI";
         string sql = @"select * from employee ";

         SqlConnection conn = new SqlConnection(connString);
         SqlDataAdapter da = new SqlDataAdapter(sql, conn);
         da.Fill(dataSet1, "employee");

         textBox1.DataBindings.Add("text", dataSet1, "employee.firstname");
         textBox2.DataBindings.Add("text", dataSet1, "employee.lastname");
  
         bMgr = this.BindingContext[dataSet1, "employee"];
      }

      private void buttonNext_Click(object sender, System.EventArgs e) {
         bMgr.Position += 1;    
      }

      private void buttonBack_Click(object sender, System.EventArgs e) {
         bMgr.Position -= 1;
      }
    }



           
       
Related examples in the same category
w___ww__.__ja_v___a2_s.c__o___m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.