Click here to Skip to main content
16,008,490 members
Home / Discussions / C#
   

C#

 
GeneralInserting Table into Data Set in Compact frame work Pin
praveenpavan12-Aug-05 2:03
praveenpavan12-Aug-05 2:03 
GeneralActiveMdiChild Problem Pin
Sheel Gohe12-Aug-05 1:56
Sheel Gohe12-Aug-05 1:56 
GeneralDataAdapter.Update Method Exception: "Concurrency Voilation: the update command affected 0 records..." Pin
signbit12-Aug-05 1:14
signbit12-Aug-05 1:14 
QuestionHow to change the Color of Tittle bar in a Windows Form? Pin
pubududilena12-Aug-05 1:07
pubududilena12-Aug-05 1:07 
QuestionHow to Color Tool Bars using C#? Pin
pubududilena12-Aug-05 1:04
pubududilena12-Aug-05 1:04 
GeneralPrinting in C#.net Pin
Ming Luo12-Aug-05 1:02
Ming Luo12-Aug-05 1:02 
GeneralRe: Printing in C#.net Pin
Guffa12-Aug-05 2:00
Guffa12-Aug-05 2:00 
GeneralRe: Printing in C#.net Pin
Marshall12-Aug-05 2:06
Marshall12-Aug-05 2:06 
Ming Luo wrote:
I want to print a document out with A4 paper size programmatically.

The prefered method is to allow the user to select the paper size since their needs may change after the application is released. To do this, implement a PageSetupDialog. If A4 is the default paper size for the printer, it will already be set in the dialog. If it is not the default size, I believe you could create a PaperSize object, set it to a PaperKind of A4 in PageSettings before printing (or showing the PageSetupDialog). Check the MSDN documentation on PageSettings[^] and PaperKind Enumeration[^].

To implement PageSetupDialog, you can use this code snip from the MSDN article[^] on PageSetupDialog Class in a print button handler. (Note this code assumes a ListBox named ListBox1 that will display the settings (used to indicate how to get the values after the user clicks OK in the dialog) and a PageSetupDialog named PageSetupDialog1.

        // Initialize the dialog's PrinterSettings property to hold user<br />
        // defined printer settings.<br />
        PageSetupDialog1.PageSettings = <br />
            new System.Drawing.Printing.PageSettings();<br />
<br />
        // Initialize dialog's PrinterSettings property to hold user<br />
        // set printer settings.<br />
        PageSetupDialog1.PrinterSettings = <br />
            new System.Drawing.Printing.PrinterSettings();<br />
<br />
        //Do not show the network in the printer dialog.<br />
        PageSetupDialog1.ShowNetwork = false;<br />
<br />
        //Show the dialog storing the result.<br />
        DialogResult result = PageSetupDialog1.ShowDialog();<br />
<br />
        // If the result is OK, display selected settings in<br />
        // ListBox1. These values can be used when printing the<br />
        // document.<br />
        if ( result == DialogResult.OK)<br />
        {<br />
            object[] results = new object[]{ <br />
                PageSetupDialog1.PageSettings.Margins, <br />
                PageSetupDialog1.PageSettings.PaperSize, <br />
                PageSetupDialog1.PageSettings.Landscape, <br />
                PageSetupDialog1.PrinterSettings.PrinterName, <br />
                PageSetupDialog1.PrinterSettings.PrintRange};<br />
            ListBox1.Items.AddRange(results);<br />
        }


If this doesn't work for you or give you enough clues, post back and let us know.

Marshall

If you continue to do the same things you always did,
don't be surprised if you get the same results you always got.

GeneralRe: Printing in C#.net Pin
Ming Luo12-Aug-05 2:20
Ming Luo12-Aug-05 2:20 
GeneralRe: Printing in C#.net Pin
Marshall12-Aug-05 2:41
Marshall12-Aug-05 2:41 
GeneralRe: Printing in C#.net Pin
| Muhammad Waqas Butt |14-Aug-05 2:41
professional| Muhammad Waqas Butt |14-Aug-05 2:41 
QuestionWhich child has been brought to front? Pin
bouli12-Aug-05 0:31
bouli12-Aug-05 0:31 
AnswerRe: Which child has been brought to front? Pin
mav.northwind12-Aug-05 0:52
mav.northwind12-Aug-05 0:52 
GeneralRe: Which child has been brought to front? Pin
bouli12-Aug-05 0:54
bouli12-Aug-05 0:54 
Generaltry catch and return value Pin
Os Sutrisno12-Aug-05 0:00
Os Sutrisno12-Aug-05 0:00 
GeneralRe: try catch and return value Pin
Colin Angus Mackay12-Aug-05 0:19
Colin Angus Mackay12-Aug-05 0:19 
GeneralRe: try catch and return value Pin
Os Sutrisno12-Aug-05 0:34
Os Sutrisno12-Aug-05 0:34 
GeneralRe: try catch and return value Pin
Colin Angus Mackay12-Aug-05 0:38
Colin Angus Mackay12-Aug-05 0:38 
GeneralRe: try catch and return value Pin
Os Sutrisno12-Aug-05 0:40
Os Sutrisno12-Aug-05 0:40 
QuestionRow colors in DataGrids? Pin
kbalias11-Aug-05 23:56
kbalias11-Aug-05 23:56 
AnswerRe: Row colors in DataGrids? Pin
Alomgir Miah12-Aug-05 6:16
Alomgir Miah12-Aug-05 6:16 
GeneralImage Capture Pin
Member 217284911-Aug-05 23:26
Member 217284911-Aug-05 23:26 
GeneralRe: Image Capture Pin
Kimocat12-Aug-05 13:35
Kimocat12-Aug-05 13:35 
GeneralResizing Gif-images that is transparent Pin
thomasa11-Aug-05 22:21
thomasa11-Aug-05 22:21 
Generalquestion on using ref keyword Pin
ppp00111-Aug-05 22:13
ppp00111-Aug-05 22:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.