|
1. Install our DataMatrix .NET Control and start Microsoft Visual Studio. Create a new project after that. ![]() 2. Register DataMatrix .NET Control in your application. Open Toolbox for that. ![]() 3. Right-click to open the context menu and select Customize Toolbox. ![]() 4. Switch to the .NET Framework Components tab and click the Browse button. Then select the file Barcodes.DataMatrix.dll. ![]() 5. Now the DataMatrix .NET Control is present on the Windows Forms tab. You can put it on the form. ![]() 6. Adjust the properties of the DataMatrix .NET Control. ![]() 7. Place the code for using the control. The following code saves the datamatrix image to an image file. The datamatrix barcode will have x-dimension equal to 4 pixels. double w, h;Copies the DataMatrix bar code image to the clipboard. dataMatrixControl1.CopyToClipboard( 200, 200 );The DataMatrix barcode can be displayed in any Graphics object or Device Context (HDC). Graphics gr = this.CreateGraphics();This code allows you to print the barcode on the printer. private void button4_Click(object sender, System.EventArgs e) { try { PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler( this.OnPrintBarcodePage ); pd.Print(); } catch( Exception ex ) { MessageBox.Show( ex.Message ); } } // The OnPrintBarcodePage event is raised for each page to be printed. private void OnPrintBarcodePage(object sender, PrintPageEventArgs ev) { double wMM, hMM; dataMatrixControl1.GetMatrixSize( 1, (int)ev.Graphics.DpiX, (int)ev.Graphics.DpiY, Barcodes.DataMatrix.Dimensions.dmMM, Barcodes.DataMatrix.Dimensions.dmMM, out wMM, out hMM ); // print a datamatrix barcode dataMatrixControl1.DrawMatrixToSize(10, 10, wMM, hMM, Barcodes.DataMatrix.Dimensions.dmMM, ev.Graphics ); } The installation package contains the entire example of how to use our DataMatrix .NET Control. The example is written in MS C#. |