Solution for printing listview

Source: Internet
Author: User
Solution for printing listview
Author: Yangtze River Tributary

Keywords:. net, printing, listview printing, and two-dimensional data
Date: 2005-12-12

Many netizens who use MIS gold printing frequently send emails asking how to print the listview. There are also many friends on the Internet who want to print the listview. You can download the MIS gold print source code print listview from my website.

I did not aim at a specific grid when developing a print core program, but for general purpose. The principles of MIS gold printing and the principle of step by step have been illustrated. You can take a look at it or print it yourself.

Many print programs are designed for specific grid controls such as DataGrid printing. However, for general purposes, what should we do?

The core of the implementation is to print two-dimensional data, and draw lines to form a grid. Multiple grids form reports and documents. What about printing text? Haha, it's still a grid. It's just a row and a column. You don't need to draw grid lines. Someone may ask, can my reports or document contracts be implemented if they are too complicated? The answer is yes. We can combine multiple grids to merge cells in the grid.

Listview is almost a two-dimensional form. The following provides a two-dimensional array for converting listview.

Convert listview to a two-dimensional array

/// <Summary>
/// Export the listview data to a two-dimensional array.
/// </Summary>
/// <Param name = "listview"> two-dimensional data view </param>
/// <Param name = "includecolumntext"> whether to export the column title text to the array. </Param>
/// <Remarks>
/// <Author> Yangtze River Tributary </author>
/// <Date> </date>
/// <Modify> </modify>
/// </Remarks>
/// <Returns> two-dimensional array. </Returns>
Public String [,] tostringarray (listview, bool includecolumntext)
{
Listview LVW = listview;
Int rowscount = LVW. Items. count;
Int colscount = LVW. Columns. count;

// Includes the column title
If (includecolumntext)
{
Rowscount ++;
}

String [,] arrreturn = NULL;
 
Arrreturn = new string [rowscount, colscount];

Int I = 0;

If (includecolumntext)
{
// Write the title
For (I = 0; I <colscount; I ++)
{
Arrreturn [0, I] = LVW. Columns [I]. text;
}

I = 1;
}

// Write the data row items
Int rowindex = 0;
For (; I <rowscount; I ++, rowindex ++)
{
For (Int J = 0; j <colscount; j ++)
{
Arrreturn [I, j] = LVW. items [rowindex]. subitems [J]. text;
}
}

Return arrreturn;
}

Print listview:

Private void btnprinteasy_click (Object sender, system. eventargs E)
{
Misgoldprinter webmis = new misgoldprinter (); // print component
Webmis. Title = "mis gold print/nwww. webmis. com. cn"; // grid title
Webmis. datasource = tostringarray (listview, true); // print any two-dimensional data
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 print component
Webmis = new misgoldprinter
Webmis. Title = "mis "+ vbcrlf + "www. webmis. com. cn" 'grid title
Webmis. datasource = tostringarray (listview, true) 'any two-dimensional data can be printed
Webmis. Preview () 'print preview
End sub

Related content:

1> principles of MIS gold printing and implementation of step by step

2> the print page settings, printer settings, and print preview dialog box are encapsulated (view document)

3> understand the principles of VB. NET and C # printing pages, and implement complete documentation and paging printing (view Documentation)

Download: printerpagesetting

Download: MIS gold print

For information on source code download, visit:
Http://blog.csdn.net/flygoldfish

Disclaimer: This article is copyrighted by Zhou fangyong. You are welcome to reprint it. Please keep the complete content and source.
Flygoldfish@163.com

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.