Code Examples

Studying, building, and modifying code examples is the perfect way to learn to use the List & Label report generator in a hands-on way. Below are several examples for major programming languages. Download your free trial version of List & Label for even more ready-to-use code examples.

Download Free Trial

Starting the Designer

protected void button1_Click (object sender, System.EventArgs e)
{
    try
    {
         // Bind to a DataSet object
         LL.SetDataBinding(myDataSet, "Orders");

         // Set Properties          LL.AutoDesignerFile  = "subreport.lst";          LL.AutoProjectType  = LlProject.List;          LL.AutoDialogTitle  = "Sample";          LL.AutoShowSelectFile = true;

         // Call the Designer          LL.Design();     }    // Catch Exceptions:    catch (Exception LlException)    {          MessageBox.Show("Information: " +                   LlException.Message,"Information",                  MessageBox.IconInformation | MessageBox.OK);     } }



Printing

private void button2_Click(object sender, System.EventArgs e)
{
     try
     {
          // Bind to a DataSet object
          LL.SetDataBinding(myDataSet, "Orders");

          // Set Properties           LL.AutoDesignerFile  = "subreport.lst";           LL.AutoProjectType  = LlProject.List;           LL.AutoDialogTitle  = "Example";           LL.AutoShowSelectFile = true;              // Start Print           LL.Print();      }     // Catch Exceptions:     catch (Exception LlException)     {         MessageBox.Show("Information: " +                 LlException.Message,"Information",                 MessageBox.IconInformation | MessageBox.OK);     } }

Starting the Designer

{Start the Designer} 
procedure TForm1.DesignButtonClick(Sender: TObject);
begin
     //Assign data source
     LL.DataSource := dsCustomers;

     //Pass customer data as fields      LL.AutoMasterMode := mmAsFields;

     //Set the default project name      LL.AutoDesignerFile := 'subrep.lst';

     //Switch print mode to preview      LL.AutoDestination := adPreview;

     //Call Designer      LL.AutoDesign('Invoice List', ''); end;



Printing

{Printing} 
procedure TForm1.PrintButtonClick(Sender: TObject);
begin
     //Assign data source
     LL.DataSource := dsCustomers;

     //Pass customer data as fields      LL.AutoMasterMode := mmAsFields;

     //Set the default project name      LL.AutoDesignerFile := 'subrep.lst';

     //Switch print mode to preview      LL.AutoDestination := adPreview;

     //Print      LL.AutoPrint('Invoice List', ,); end;

Starting the Designer

// normal text field:
LlDefineFieldExt(job, "Text", "Testtext",LL_TEXT, NULL);

// Footer field, i.e. numeric: LlDefineFieldExt(job, "Subtotal", "12.34",   LL_NUMERIC | LL_TABLE_FOOTERFIELD, NULL);

// Barcode field: LlDefineFieldExt(job, "BC_EAN_128", "123456789abcd",   LL_BARCODE_EAN128, NULL);

// Variable graphics by file name: LlDefineFieldExt(job, "Regular Graphic","sunny.bmp",   LL_DRAWING, NULL);

// File open dialog with sketch: LlSelectFileDlgTitleEx(job, hWnd, "File open",   LL_PROJECT_LIST, szFile,sizeof(szFile), NULL);

// Remove a certain menu command from the Designer: LlDesignerProhibitAction(job, 211);

// Start the Designer with the above fields: LlDefineLayout(job, hWnd, "Title", LL_PROJECT_LIST, szFile);



Printing


// Define special fields, regular text field:
  LLDefineFieldExt(job, "Text", "Testtext",LL_TEXT, NULL);

  // Numeric field:   LLDefineVariableExt(job, "Subtotal", "12.34",     LL_NUMERIC | LL_NUMERIC, NULL);

  // Barcode field:   LLDefineVariableExt(job, "BC_EAN_128", "123456789abcd",     LL_BARCODE_EAN128, NULL);

  // Variable graphic by file name:   LLDefineVariableExt(job, "Graphic","sunny.bmp", LL_DRAWING, NULL);

  // Start printing:   LlPrintWithBoxStart(job, LL_PROJECT_LABEL, szFile,     LL_PRINT_EXPORT, LL_BOXTYPE_BRIDGEMETER, hWnd, "Printing...");     //Print label:     nErrorValue = LlPrint(job);

  // End printing:   LlPrintEnd(job,0);

Starting the Designer

Private Sub ButtonDesign_Click()

'Start the Designer with the title "Invoice" and the file "invoice.rpt":    ListLabel1.Design(0, hWnd, "Invoice", LL_PROJECT_LIST, "invoice.rpt", 1)

End Sub For data definition the event ListLabel1_CmndDefineFields is used.


Printing

Private Sub ButtonPrint_Click()

  'Print the project "test.lst" on the printer
  Data1.Recordset.MoveFirst
  ListLabel1.Print(0, LL_PROJECT_LIST, "test.lst",_
    True, LL_PRINT_NORMAL, LL_BOXTYPE_NORMALWAIT, hWnd,_
    "Print, True, Environ$("temp"))

End Sub

Private Sub ListLabel1_CmndDefineFields(ByVal nUserData As Long,
  ByVal bDummy As Long, nProgressInPerc As Long, pbLastRec As Long)
  'This event is called by the commands Print and Design
  'It is called for each record to declare the fields and
  'their contents to List & Label
  'Repeat for all fields of a 'record
  For i = 0 To Form1.Data1.Recordset.Fields.Count - 1
    content$ = Data1.Recordset.Fields(i)
    nRet = ListLabel1.LlDefineFieldExt _
      (Data1.Recordset.Fields(i).Name, content$, LL_TEXT)
  Next i
  'Skip to next record:
  Form1.Data1.Recordset.MoveNext
  'Stop printing if last record is reached:
  If Form1.Data1.Recordset.EOF = True Then
    pbLastRec = 1
  End If

End Sub

Download Free Trial

Last update: 2014-03-06
+1 800 256 3608 (toll-free in the US)