Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate Combo with Printer Info

Status
Not open for further replies.

DESMAN2003

Programmer
Oct 27, 2003
24
AU
Hi, does anyone know how to populate a combo box with the PC's printers? In order words, I want to be able to select all the printers my computer can use through a combo box. Any ideas???

Thanks in advance!
 
Code:
private void PopulateInstalledPrintersCombo()
{
// Add list of installed printers found to the combo box.
	for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
	{
	comboBox1.Items.Add(PrinterSettings.InstalledPrinters[i]);
	}
}
-obislavu-
 
You have to add :
using System.Drawing.Printing;
-obislavu-
 
Hi,

I tried what you said and it compiles, but the combo is empty. Would you know how to fix this?

Thanks.
 
If you go to Start | Settings | Printers, how many printers are listed there? That's the list it's getting.

Your code will also need the PrintingPermission granted to it. If you're running off your local machine (and not over a network share), then you should already have full access, which includes PrintingPermission.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
I have 4 printers installed but they dont show up. Is there any other reason why you think it doesnt work?

thanks.
 
It is possible to add the items in a ComboBox and you look in another ?
Did you clicked on the ComboBox to show up the list?
With the code that I provided I have all items listed in Control Panel->Printers and Faxes in the ComboBox.
Before printing you have to access the printer name through PrintDocument class.

-obislavu-

 
Its very strange. I added into the items box one of the printers that is on my computer. When I run the program, I select this printer (its the only one there) and then when I click on the combo box again, I suddenly can see all the printers! The problem is that I want to be able to see them all without have to pick one first. Do you know how to fix this problem?
 
Where did you put the code that populate the combobox ?
Could be related with ResumeLayout() call.

-obislavu-
 
For the code that you gave me I double-clicked on the combo and pasted it there. Then the printer info I put in the Items areas (properties). Is that right?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top