473,387 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

get the default printer

Hello,
You can use the PrintDocument component to use the
default printer. If you don't specify a printer to the
PrintDocument object, by default, it will
use the default printer.
This is a sample code;

private void print_Click(object sender, System.EventArgs
e)
{
printDocument1.Print(); //It will use default
printer
}

private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Red, new Rectangle
(500, 500, 500, 500));
}

If you dont want to print a document, but just want to
retrieve the information about the default printer. You
can create a PrintDocument and access its PrinterSettings
Property. You can get the information such as PinterName
and PaperSize from the Property.

PrintDocument printDocument1 = new PrintDocument();
MessageBox.Show
(printDocument1.PrinterSettings.PrinterName);

For more information about PrintDocument please see:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/cpref/html/
frlrfSystemDrawingPrintingPrintDocumentClassTopic. asp

I hope this is helpful for you.

Ravikanth[MVP]

-----Original Message-----
Friends,

how can i get the name of the default printer??. I'm
working with winforms. VB,C#, nevermind.

Thanks a lot
Pablo
.

Nov 15 '05 #1
1 21396
Thanks for answering.
However this is not useful for me as i'm sending to print
through a Word object which automatically sends to the
default printer.
That is why i have to change it before sending (i've
already achieved this) and then return to the previous
settings.
If you have another suggestion, please let me know.
Thanks
Pablo
-----Original Message-----
Hello,
You can use the PrintDocument component to use the
default printer. If you don't specify a printer to the
PrintDocument object, by default, it will
use the default printer.
This is a sample code;

private void print_Click(object sender, System.EventArgs
e)
{
printDocument1.Print(); //It will use default
printer
}

private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Red, new Rectangle
(500, 500, 500, 500));
}

If you dont want to print a document, but just want to
retrieve the information about the default printer. You
can create a PrintDocument and access its PrinterSettingsProperty. You can get the information such as PinterName
and PaperSize from the Property.

PrintDocument printDocument1 = new PrintDocument();
MessageBox.Show
(printDocument1.PrinterSettings.PrinterName);

For more information about PrintDocument please see:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/cpref/html/
frlrfSystemDrawingPrintingPrintDocumentClassTopic .asp

I hope this is helpful for you.

Ravikanth[MVP]

-----Original Message-----
Friends,

how can i get the name of the default printer??. I'm
working with winforms. VB,C#, nevermind.

Thanks a lot
Pablo
.

.

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pablo | last post by:
Friends, how can i get the name of the default printer??. I'm working with winforms. VB,C#, nevermind. Thanks a lot Pablo
0
by: Esmee | last post by:
Hi there, I have created an Access 2002 db which contains several reports. Some reports need to be printed on a Laserjet and others on a Labelprinter. One of my clients wants to be able to print...
2
by: MLH | last post by:
I would like to allow users to set, as an application default, a specific printer to send reports to. I don't know how to bring up a list of valid print devices in A97, nor do I know how to...
2
by: Willem | last post by:
Hi, I'm trying to get the default printer using WMI. I use the following code: Private Function GetDefaultPrinter() As String Dim objWMIService As Object Dim colInstalledPrinters As Object...
3
by: Raymond Martin | last post by:
How do I find out if the default printer is offline or online (or has a paper jam)?
0
by: Karthick_Microsoft | last post by:
Actually, in my ASP.Net application, i have a requirement of automatically changing the default printer. I did a OCX using VB and put it on the web page. The client machines do not have local...
1
by: i8mypnuts | last post by:
Could someone please help? I am using the 'defaultprt.zip' tool provided by Ken Getz to change the default printer via VBA code (code below). My problem is that once the default printer has been...
1
by: groulder | last post by:
hi all, i have a problem with a network database that's used by a lot of people. people are finding, they will start the database, and if the mouse is moved over the print icon, the tooltip...
2
sashi
by: sashi | last post by:
Set default printer You will often find yourself in a position where you have designed a report format for one printer and when that report is sent to another printer the layout is messed up. ...
3
by: brianflannery | last post by:
Greetings all! My problem is this. I've installed a new printer on my computer. This is the "default printer" for access. Now, some of my reports, which were working fine with the old printer,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.