Barcode Data Binding in Windows Forms

Neodynamic

Well-known member
Joined
Dec 5, 2005
Messages
137
Programming Experience
10+
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:

figure01Small.jpg


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


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



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

Visual Basic .NET
bmbProducts.Position -= 1



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

Visual Basic .NET
bmbProducts.Position += 1



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

figure02.jpg


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


Neodynamic
.NET Components & Controls
Neodynamic
Neodynamic Barcode Professional for .NET Windows Forms
 

Latest posts

Back
Top