Articles

Printing in .Net 2.0

Image
Enable printing in your .net windows applications: Supporting printing in your .net application is a simple process. In this article I'll show you of printing in your .net 2.0, how you can configure page setup, print multiple pages, and preview a document before being printed, as well as let users select a printer to which to print.   Creating the sample application: Open Visual Studio 2005; create a new Windows application project using C#: Figure 1.   In .NET, all the printing functionality is encapsulated within the PrintDocument control which can be found in the ToolBox. The PrintDocument control defines various methods that allow you to send output to the printer.   To incorporate printing functionality into you Windows application, you can simply drag and drop the PrintDocument control on to your form (see Figure 2), or create an instance of the PrintDocument class during runtime. Figure 2   There are generally three events that you need to ...

Printing in Winforms

Image
Introduction Vb.net has a PrintForm method but C# does not have inbuilt method for printing a windows form.The following procedure enables us to print a windows form at runtime in c#.net.The base concept involves the capture of  the screen image of the windows form in jpeg format during runtime and printing the same on a event like Print button click. Open a new windows form project and add a new windows form. Include simple controls(label,textbox,button) on the form.From the toolbox,include PrintDialog,PrintDocument components in the form. In the code behind Include the following namespaces using System.Drawing.Imaging; using System.Drawing.Printing; and import the following .dll for the necessary GDI functions [System.Runtime.InteropServices. DllImportAttribute ( "gdi32.dll" )] The following code is placed in the declaration section of the form. The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the sp...

Printing in C#

Printing Using C# - Creating a Printing Application           Printing Using C# (Page 1 of 7 ) In this article Matthew shows us how to build a print engine in C# allowing us to print our application data easily. Editor's Note: This article's code has been updated to work with the final release of the .Net framework. Those of you who have done any programming with the Win32 API will be familiar with the concept of the Device Context, also known as the "DC". A Device Context allows a developer to draw things like text, lines, rectangles, curves, etc. on both the screen and the printer, or even in memory in preparation for later drawing to either of these devices. This was a pretty powerful arrangement that allowed a developer who knew how to draw application output on the screen to draw application output on a printer. With .NET, we're given a variety of graphics classes that eventually allow drawing of certain graphics primitives...