Wednesday, September 14, 2005

Barcode Data Binding in .NET Windows Forms 2.0

One of the enhancements in .NET 2.0 is the new Windows Forms Data Binding capabilities. You can create with few steps and time data-enabled forms using Visual Studio .NET 2005. Select a Data Source (provided by a Web Service, a Database, or a Business Entity) and then specify for each data source’s “field” a Windows Forms Control that will represent it onto the form (Data Source pane on figure). You can enable your custom control for data-binding adding a simple class-level Metadata Attribute. There’re tree different attributes to use depending on your needs, DefaultBindingPropertyAttribute, ComplexBindingPropertiesAttribute, or LookupBindingPropertiesAttribute. In our case we just use the first one.
If you do not do that, your control will not be allowed to participate in the data-binding process as is stated in .NET 2.0 help:

"You can modify the list of controls associated with each data type by selecting Customize from the list attached to any item in the Data Sources window. The list of Associated controls is determined by the available controls in the Toolbox that implement one of the following databinding attributes: DefaultBindingPropertyAttribute, ComplexBindingPropertiesAttribute, or LookupBindingPropertiesAttribute."

Realize that your control must be in the Toolbox before you can bind it with any data type.
Here, a screenshot of our Barcode Professional 2.5 for Windows Forms 2.0 under beta at this moment.

Tuesday, September 13, 2005

ASP.NET Atlas Project available

Today, the ASP.NET Team officially launched its Atlas project. I saw the PDC05 Keynote where Scott showed a sample app using an Atlas server control that renders maps using Virtual Earth… very impressed.
Atlas is available to download and we can try it using VS.NET 2005 Beta 2. I’ll download it and see what we can do with it.
PS: Scott has wrote great stuff about Atlas

Thursday, September 08, 2005

Concatenating Byte Arrays

I needed to concatenate two byte arrays. My first thought was to create a destination buffer and then loop through each sources adding their elements to the destination one – something dirty ah!
Fortunately, before to write any line of code I found this beautiful class called Buffer in the System namespace.
So, how you can concatenate two byte arrays using it? Very simple:

byte[] b1 = new byte[]{1,2,3};
byte[] b2 = new byte[]{4,5,6,7,8,9};

byte[] c = new byte[b1.Length + b2.Length];

Buffer.BlockCopy(b1, 0, c, 0, b1.Length);
Buffer.BlockCopy(b2, 0, c, b1.Length, b2.Length);


That’s it. Thanks BCL folks!