General table printing example

Source: Internet
Author: User

// In this example, the common table printing 1 or 2 is required, and the interface is used together with code128 barcode generation.

Sing system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. LINQ;
Using system. text;
Using system. Windows. forms;
Using cyh. General;

Namespace demotablexreport
{
Public partial class form1: Form
{
Private dataset dataset1;
Public form1 ()
{
Initializecomponent ();

}

Private void form1_load (Object sender, eventargs E)
{

// Read data to Dataset
Dataset1 = new dataset ();
Dataset1.readxml (application. startuppath + "\ testreport. xml", system. Data. xmlreadmode. readschema );
Datagridview1.datasource = dataset1;
Datagridview1.datamember = dataset1.tables [0]. tablename;
}

Private void button#click (Object sender, eventargs E)
{
Itablereport XTR = new ctltablereport ();
XTR. addreporttitle ("test 1 (center)", true, null, stringalignment. Center, size. Empty );
XTR. addreporttitle ("test 2 (FAR)", true, null, stringalignment. Far, size. Empty );
XTR. addreporttitle ("test 1 (center)", false, null, stringalignment. Center, size. Empty );
XTR. addreporttitle ("test 2 (near) {0}", false );
XTR. addreportfield ("part number", null, "drug catalog", stringalignment. Near, null, false, String. Empty, true, String. Empty, size. Empty );
XTR. addreportfield ("name", "name ");
XTR. addreportfield ("gauge 2", null, "type", stringalignment. Near, null, false, "Total", false, String. Empty, size. Empty );
XTR. addreportfield ("zero price 3", null, "retail price", stringalignment. far, null, false, "", true, "{0: #0.00}", size. empty );
XTR. setreportbarcode ("a202010", new point (100, 0), new size (500,100), true, String. Empty );
// Int r = XTR. getautorow (dataset1.tables [0]. Rows. Count, 40 );
// XTR. setreportmain (100, R, reportgridline. nothing, stringalignment. center, false, new system. drawing. printing. margins (80, 80,100, 80), system. drawing. printing. paperkind. custom, size. empty, 1, 0, "", true, 1 );
XTR. setreportmain (100, 20, reportgridline. nothing, stringalignment. center, false, new system. drawing. printing. margins (80, 80,100, 80), system. drawing. printing. paperkind. custom, size. empty, 1, 0, "", false, 1 );
XTR. unitafterprint + = new reportunitafterprint (xtr_unitafterprint );
XTR. datasource = dataset1.tables [0];
XTR. showdialog ();
}
Void xtr_unitafterprint (Object sender, reportbandtype source, int pageindex, int rowindex, string caption, string field, ref string value, eventargs E)
{

// If (Source = reportbandtype. pagefooder)
// Value = string. Format ("{0}", pageindex + 1 );
// Throw new notimplementedexception ();
}
Void xtr_unitafterprint (Object sender, int source, int pageindex, int rowindex, string caption, string field, ref string value, eventargs E)
{
// Print content and format can be corrected here

}

}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.