.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Setting printer duplex programatically

Posted By:      Posted Date: September 12, 2010    Points: 0   Category :Windows Application
How do you programmatcally set a printer to duplex?   The information I've found online indicates that GetPrinter/SetPrinter should do the trick, but so far I've had mixed results.    I'm automating Microsoft Word to print documents.  Some of the documents required to be duplexed.  So far in my research I've found the following web pages that provide somewhat helpful information. http://support.microsoft.com/default.aspx/kb/315720 How to enable and disable a printer by using the SetPrinter function in Visual C# http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q140/2/85.asp&NoWebContent=1 How To Modify Printer Settings by Using SetPrinter http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q167/3/45.asp&NoWebContent=1 How To Modify Printer Settings with the DocumentProperties() Function http://support.microsoft.com/kb/828638  How to set duplex printing for Microsoft Word Automation clients (This article appears to be starting pointing for the CodeProject article) http://www.codeproject.com/dotnet/NET_Printer_Library.asp  Changing printer settings using C# I've included the code I'm using now.  I don't get any errors and everything appears to work, but the Duplex setting on the printer is not set reliably.  My check is to open the printer's properties and the "Pr

View Complete Post

More Related Resource Links

Need help on setting printer orientation in VB.NET

Hi,   I try to change some printer settings using the win32 api OpenPrinter, GetPrinter and SetPrinter in VB.Net application.I copied most of the code from this or related newsgroups. However, OpenPrinter, GetPrinter and ClosePrinter works so far but I cannot change the printer settings. SetPrinter returns the error code ACCESS DENIED. I know I have to deal with the desired access mask in the _DEFAULT_PRINTER structure when calling OpenPrinter. Unfortunaltely the declaration of the DEFAULT_PRINTER structure or class I found on the internet doesn't work with the OpenPrinter function.       Public Structure DEVMODE         Public dmDeviceName As String         Dim dmSpecVersion As Short         Dim dmDriverVersion As Short         Dim dmSize As Short         Dim dmDriverExtra As Short         Dim dmFields As Integer         Dim dmOrientation As Short         Dim dmPaperSize As Short         Dim dmPaperLength As Short         Dim dmPaperWidth As Short         Dim dmScale As Short

Questions about setting dropdownlist selection programatically

I don't understand some things about setting the current selection of dropdownlists from code. I have a dropdown list of people's names where the Value is a Person_ID.  This gets loaded from SQL, and I added an Item which is "Please select..." to the top of the list and gave it a value of 0.  AppendDataBoundItems is true.   If I want to select an item from code can I use dropdownlist.SelectedValue=8 (for example)? Do I also have to set the SelectedItem.Text or does tha above do that for me? Can I instead set the SelectedIndex to some number if I happen to know it?  Will that set the SelectedValue and SelecteItem for me? If I want to set the list back so that nothing is selected (and Please select... shows) should I set SelectedIndex=0?  Is that the same as setting SelectedValue=0 in this case (since "Please select" has a value of 0)? I guess I'm confused on which of these 3 properties I should be using, to select an item (or deselect all items) in the list, using code. Thanks.

RsClientPrint add-on does not hold Default Printer Setting

 The default printer paper size is A4 in user PC but when the print icon is pressed in the report viewer control, the paper size is shown as Letter. Is there any way to capture the correct paper size as per the default printer?   Thanks,

DropDownList SelectedIndexChanged event not fired when programatically setting SelectedValue


In our asp.net web application we load the dropdown list boxes in the page load.  We than set the SelectedValue of each dropdown list box to an object from session.  We have event handlers for many of the SelectedIndexChanged events of the drop down lists boxes, but these do not get executed when we set the selected value programmatically.


Someone else mentioned this is by design, and only when a user manually changes the drop down list selected index, will the event get raised.


I would think this is a common scenario of wanting the selectedindexchanged event handled when setting the selectedvalue/selectedindex/listitem's selected property, of a DropDownList.  What is the suggested way to handle this?  Is there a significant drawback of creating a custom control inherited from DropDownList that has the functionality of raising this event when changing the SelectedIndex or SelectedValue?



Setting Windows Services App properties programatically


I've got a Windows Services app I've deployed and I've used the System.ServiceProcess.ServiceInstaller to set the StartType to Automatic and that works great.

How do I set the action on failure to "restart" and the wait time to one minute?

Can't find those properties but if you open up a Service's properties in the UI, there's a Recovery Tab with First Failure, Second Failure etc. and a "Restart service after __ minutes"

Where do I set these properties for my service at design time before deploying??



What Do the Different Printer Options using Windows Mobile Pocket Pc

Select Printer Options:
bullet Printer: Select the printer to print to. Some printer selections work for a variety of printers, such as the "HP PCL" selection which prints to most Hewlett Packard DeskJet, LaserJet and compatible printers.
bullet Port: Select between Infrared, Bluetooth, Network printing and Serial (COM1-COM8). Most Windows CE devices only have Infrared and COM1 and need special attachments to use the other selections. USB printing and printing across an ActiveSync connection to a desktop printer is not supported.
NOTE: On many Pocket PC devices, you CANNOT use the serial and infrared ports at the same time. This means that if your device is connected to your desktop PC using the serial Sync cable, the Infrared port will not work. You must disconnect the serial connection to use Infrared printing.
bullet Color/Mono: Select Monochrome (Black & White) if your printer is not a color printer (or if you wish to print in mono). If your printer has color capabilities AND has a black ink capability, select "4-Color CMYK". If your printer cannot hold both color ink and black ink at the same time, select "3-Color CMY".
bullet Paper Size: Select paper size for use. You can choose "Custom" and then set special paper sizes in the "Custom Paper" Width and Height boxes. For printers that use "roll" paper, you can set a maximum paper height of 22 inches.

More Settings O

Setting the default start page in godaddy hosting?


 How do you set the start page with godaddy hosting? I can see no way of doing this! You do not seem to have access to the IIS settings that allow you to change it!

Setting Screen Resolution



  I am developing a website in asp.net.How can i make my web pages view same in different screen resolutions.I am using 1024*768 resolution

Error while setting up application on Win7 using Visual Studio.NET 2003


Hi All,

Getting the below error while setting up application on Win 7 using visual studio.NET 2003.


cannot find the components for communiacting with the front page server extensions...


I understand by the error, i need to install Front page server extension, but not able to figure how to install using IIS 7.5.

I had XP machine with IIS 5.1, able to find the option.


Need your help in resolving this.




How to write SQL Datasource programatically in VB


Can someone pls help me to rewrite this programatically!


<asp:SqlDataSource ID="DS" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                SelectCommand="SELECT * FROM [Products] WHERE ([ProductID] = @QSID)">
                    <asp:QueryStringParameter DefaultValue="" Name="QSID" QueryStringField="ID"
                        Type="Int32" />


Thank You in advance!


Setting default localization



I ever thought that I can set a default localization if the users one (which is set in the browser) isn't available.

I've implemented my localresource files for localization. The start.aspx.resx contains all texts and elements for German use and the start.aspx.en.resx for English users. When I switch the language in the browser settings from German to English everything works fine and the english text is displayed. But when I switch to an other language which is not German or English, it takes defaulty the german resource files.

I've set

UICulture="auto:en-US" Culture="auto:en-US"

as well, but it didn't assume the .en resource file automatically. (For example when I enter the website and switch the browser language to French or Italian it should take the english resource files.)

Thanks and regards,

Error : Polling duplex in WCF DotNet4.0


We are making sample polling duplex in .net 4.0.

when ever we are  binding this tag in web.config it shows below error.




Warning    1    The element 'bindings' has invalid child element 'pollingDuplexHttpBinding'. List of possible elements expected: 'basicHttpBinding, customBinding, msmqIntegrationBinding, netPeerTcpBinding, netMsmqBinding, netNamedPipeBinding, netTcpBinding, wsFederationHttpBinding, ws2007FederationHttpBinding, wsHttpBinding, ws2007HttpBinding, wsDualHttpBinding, netTcpContextBinding, wsHttpContextBinding, basicHttpContextBinding, mexHttpBinding, mexHttpsBinding, mexNamedPipeBinding, mexTcpBinding, webHttpBinding'.    D:\DuplexTest\TestPollingDuplexWcf\TestPollingDuplexWcf\TestPollingDuplexWcf\Web.config    9    8    TestPollingDuplexWcf

Advanced Basics: Setting Word Document Properties the Office 2007 Way


The last time I wrote this column (March 2006), I shared an application that allows you to update all the Microsoft® Word documents in a folder and its subfolders. Each time the application finds a document in the specified path, it updates the document properties to match those you specified in the application.

Ken Getz

MSDN Magazine June 2006

Setting webpage/masterpage background...image?


I want to have the background of my masterpage (the master page for all of my .aspx pages) have a sort of gradient.  I imagine the only way I can do that is with an image.  Or maybe even some other design, but I want to move away from the "solid color" background.

Is the easiest way to do this just to make an image and set that as the background?  What image size should I make it, because some users could possibly have the normal aspect ratio, or maybe a widescreen?  What should I make it like so that it looks good on all computers?

Thanks in advance. :) 

setting scroll position for a ListBox


I have a ListBox control showing 10 rows.  I have 30 rows total in the listbox.  How do I programmatically adjust the scroll to show the last ten rows?

Some sources have suggested that I set the SelectedItem.  But I am already making selections (myListBox.Items[28].Selected = true, myListBox.Items[29].Selected = true, etc); the listbox scroll is positioned on Item[0] not the first selected item.  I have also tried setting myListBox.SelectedItem in addition to the multiple selection just mentioned but that does not have any affect either.


adding programatically FilteredTextBoxExtender


 Hello, I have a problem with adding programatically FilteredTextBoxExtender (i put the code below).

The problem is that nothing is outputed when page is renedered although TextBox and FilteredTextBoxExtender are added to container (table cell controls property in my case).


TextBox tbDictionaryEntryTextBox = new TextBox();
tbDictionaryEntryTextBox.ID = "tbDictionaryEntry_" + controlNameSuffix;
tbDictionaryEntryTextBox.Width = Unit.Pixel(controlWidth);
if (isNumeric) {
      ftei = new FilteredTextBoxExtender();
      ftei.ID = "fteDictionaryEntry_" + controlNameSuffix;
      ftei.TargetControlID = tbDictionaryEntryTextBox.ID;
      ftei.FilterType = FilterTypes.Numbers;
      ftei.Enabled = true;         
Best Regards,


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend