Open Source: MIS Gold Try Condo Principle and Implement STEP BY Step (1)
Principle
As we said in printing page settings, printer settings, print preview dialog implementation, this universal class can modify itself in its own project. This class will also be used in the MIS Gold Incoming We are going to explain and have implemented, let us work together to realize your MIS printing program!
From now on, let's take a step by step to print the management information system (MIS) report, document (such as purchasing orders, ordering orders, etc.), contract (such as industrial and mining companies, multi-complex merge merge metrics, text, etc.) and many more.
Many print procedures are printed for specific grid controls such as DataGrid, but what should we think about it for universal, what do we think?
The core of the realization is to achieve the printing of two-dimensional data, plus the drawing line, forms a grid, multiple grids constitute a report, document, etc. So what about printing text? Haha, or a grid, just a row, no need to draw grid lines. Maybe someone wants to ask, my report or document is too complicated, can I realize? The answer is affirmative, we can implement the cells that combine multiple grids, merge grids.
After the above analysis, we can achieve any printing as long as you implement two-dimensional data printing and drawing two classes of a straight line or rectangle. In future implementations, we will see an IDRAW interface that contains at least one Void Draw () method, and the two core classes we have to inherit and implement DRAW (). So I have several grids to instantiate a few such objects and call Draw () is OK.
A few default and common objects are provided in MIS Gold Print Title, Caption, Top, Header, MultiHead, Body, Footer, Bottom, and misgoldprinter. Everyone knows why I offer these objects, because I basically print the title, subtitle, mesh head description, mesh headline, mematism, in order to print the report or document, I am a multi-layer header (general Chinese Take a clear table of the table, the mesh is complicated, with a few rows of multiple columns and some merged units to explain), data grid main body, main grid note, TOP and BOTTOM are above the two One line of three columns. It is the Misgoldprinter class that manages these objects to manage these objects and implement printed of any complicated reports and bills.
In several default, Top, Header, MultiHead, Body, Footer, Bottom are directly or indirectly inherited from our core classes, Title, CAPTION, although it can also be implemented with a line of grids. But I still have it to achieve it. CAPTION can set text with fonts, Title inherits in CAPTION, because Title also draws two underscores.
If you want to make a set (for example, the grid only print the cell text, the grid line does not draw), adding a set of set attributes in the misgoldprinter, or you can divide the set attribute in each object, and after judging whether or not print title, more Layer head, grid line, etc., or use Excel format, analysis, statistics, we only need to print the number of Excel that you need to print.
Our ideas are: simple and fast, easy to use
For example, we drag a command button on the window, name BtnprinteaSy, and then write down the following code, you can implement the grid print:
C #: private void btnprinteasy_click (object sender, system.eventargs e) {misgoldprinter webmis = new misgoldprinter (); // Print component webmis.title = "MIS Gold In /Nwww.webmis.com.cn"; // Title WebMis.DataSource = this.dataGrid1; // DataGrid as a data source, or any two-dimensional array WebMIS.PREVIEW (); // Print preview} vb.net :private sub btnprinteasy_click (Byval Sender as system.Object, Byval e as system.eventargs) Handles Btnprinteasy.Click Dim Webmis As misgoldprinter 'printing component webmis = new misgoldprinter webmis.title = "MIS Gold Intensity" VBCRLF "www.webmis.com.cn"' grid headline Webmis. DataSource = Me.DataGrid1 'DataGrid as data source WebMIS.PREVIEW () print preview END SUB
Of course, don't forget the following code, we have to write some test data for DataGrid. The practice is to double-click the window blank, call the window Form1_Load event, as follows: C #:
Private void form1_load (object sender, system.eventargs e) {this.dataGrid1.datasource = this.getdataSource ();
Private DataTable getDataSource () {dataable dt = new dataable ();
INT rows = 50; int cols = 6;
// Increase line for (int introwindex = 0; Introwindex INT I, J; For (i = 0; i VB.NET: Private Sub Form1_Load (Byval E AS System.EventArgs) Handles mybase.load me.DataGrid1.datasource = me.GetDataSource () End Sub Private function getDataSource () as system.data.dataable DTT AS NEW System.Data.DataTable Dim Rows, Cols As Int32 Rows = 50 COLS = 6 DIM I, J AS INT32 I = 0 While (i I = 0 while (i For i = 0 to rows - 1 for j = 0 to cols - 1 dt.rows (i) (j) = (i 1) .tostring () "row" (j 1) .tostring () "Column" DT.ROWS (I) (COLS - 3) = (J 1) .tostring () "." (I 1) .tostring () DT.ROWS (i) (cols - 2) = (i 1) .tostring () Next DT.ROWS (i) (COLS - 1) = (Double.Pars (Dt.Rows (i) (COLS - 2) .tostring ()) * double.PARSE (DT. ROWS (I) (COLS - 3) .tostring ())). Tostring () Next Return DT End Function Private Sub Form1_Load (Byval E AS System.EventArgs Handles mybase.load me.DataGrid1.datasource = me.GetDataSource () End SUB how? Is it really not complicated? If we still want to change the fonts of the title Title, we can do it easily. We can also set up subtitles, headers, headers, headers, footer, and mesh. In short, you can easily get printed without having to do a lot. We will implement print by Step by Step in a step by step, step by step, one step, one step, after you have finished reading, you will feel: Print, manage the eternal topic of the information system, and I, you can achieve it yourself. . Disclaimer: This article is copyright to Zhou Fangyong [Yangtze River Burning] All, if you need to reprint, please keep the full content and source. Flygoldfish@sina.com