borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincani

AndreaVB Home | News Home | Forum Home | Downloads | Register | Search | PM | Profile

Previous Topic (Infopath multiple views & accessing XSD schema via Aspose.Form)Next Topic (Image formats & Composite fonts supported by Aspose.Recognition) New Topic Post Reply
AndreaVB OnLine : News : Barcode Data Binding in Windows Forms
Poster Resource
Neodynamic
Level: Master

Registered: 08-12-2005
Posts: 131
icon Barcode Data Binding in Windows Forms

Technologies used
- Neodynamic Barcode Professional for Windows Forms (any version)
- Microsoft .NET Framework 1.0 or greater
- Microsoft Visual Studio .NET 2002 or 2003
- Microsoft Visual Studio 2005
- Microsoft Visual Studio 2005 Express Editions (VB, C#, J#, and C++)

In the following step by step guide we're going to create a simple Windows Forms application that accomplishes data binding tasks. In this sample we use Microsoft's Northwind database sample for SQL Server.

Follow these steps:
1- Ensure you have installed Barcode Professional for Windows Forms
2- Launch Visual Studio and create a new Windows Forms application
3- Open the default Form at design-time and add the following controls as is shown in the following figure:

    

4- Now, go to the form class and add the following code:
4.1- Declare this two members variables

     Visual Basic .NET
     Dim ds As DataSet
     Dim bmbProducts As BindingManagerBase

     Visual C# .NET
     DataSet ds;
     BindingManagerBase bmbProducts;

4.2- Add the following code in the Form_Load event procedure VB.NET

     Visual Basic .NET
     Dim cnn As New System.Data.SqlClient.SqlConnection("server=(local);database=Northwind;integrated security=true")
     Dim sqlcmd As New System.Data.SqlClient.SqlCommand("SELECT Products.ProductName, Categories.CategoryName, Products.UnitPrice, Products.ProductID FROM Products INNER JOIN Categories ON Products.CategoryID = Categories.CategoryID", cnn)
     Dim da As New System.Data.SqlClient.SqlDataAdapter(sqlcmd)

     ds = New DataSet
     da.Fill(ds, "Products")

     bmbProducts = BindingContext(ds, "Products")

     TextBox1.DataBindings.Add("Text", ds, "Products.ProductName")
     TextBox2.DataBindings.Add("Text", ds, "Products.CategoryName")
     TextBox3.DataBindings.Add("Text", ds, "Products.UnitPrice")
     BarcodeProfessional1.DataBindings.Add("Code", ds, "Products.ProductID")

     BarcodeProfessional1.Text = ""
     BarcodeProfessional1.Symbology = Neodynamic.WinControls.BarcodeProfessional.Symbology.Industrial2of5

     Visual C# .NET
     System.Data.SqlClient.SqlConnection cnn = new System.Data.SqlClient.SqlConnection("server=(local);database=Northwind;integrated security=true");
     System.Data.SqlClient.SqlCommand sqlcmd = new System.Data.SqlClient.SqlCommand("SELECT Products.ProductName, Categories.CategoryName, Products.UnitPrice, Products.ProductID FROM Products INNER JOIN Categories ON Products.CategoryID = Categories.CategoryID", cnn);
     System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(sqlcmd);

     ds = new DataSet();
     da.Fill(ds, "Products");

     bmbProducts = BindingContext[ds, "Products"];

     TextBox1.DataBindings.Add("Text", ds, "Products.ProductName");
     TextBox2.DataBindings.Add("Text", ds, "Products.CategoryName");
     TextBox3.DataBindings.Add("Text", ds, "Products.UnitPrice");
     BarcodeProfessional1.DataBindings.Add("Code", ds, "Products.ProductID");

     BarcodeProfessional1.Text = "";
     BarcodeProfessional1.Symbology = Neodynamic.WinControls.BarcodeProfessional.Symbology.Industrial2of5;

4.3- Add the following code in the Click event procedure for << Previous button

     Visual Basic .NET
     bmbProducts.Position -= 1

     Visual C# .NET
     bmbProducts.Position -= 1;

4.4- Add the following code in the Click event procedure for Next >> button

     Visual Basic .NET
     bmbProducts.Position += 1

     Visual C# .NET
     bmbProducts.Position += 1;

5- That's it. Run the app. You'll get something like the following:

  

Links:
This Demo
More Demos
Download Barcode Professional for Windows Forms
More Information about Neodynamic Barcode Professional for Windows Forms


Neodynamic
.NET Components & Controls
http://www.neodynamic.com
http://www.barcode-for-net.com

26-05-2009 at 05:26 PM
View Profile Send Email to User Show All Posts Visit Homepage | Add Comment
AndreaVB OnLine : News : Barcode Data Binding in Windows Forms
Previous Topic (Infopath multiple views & accessing XSD schema via Aspose.Form)Next Topic (Image formats & Composite fonts supported by Aspose.Recognition)New Topic Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder