Hello,
Is there a way to call a printDialog from a printPreviewDia log (from print
icon for example)?
Indeed, the print icon in the printpreviewdia log prints directly the
document without lunching the printdialog (i.e. the user can't choose the
print parameters).
Thanks a lot. 10 15337
choupi wrote:
Hello,
Is there a way to call a printDialog from a printPreviewDia log (from print
icon for example)?
Indeed, the print icon in the printpreviewdia log prints directly the
document without lunching the printdialog (i.e. the user can't choose the
print parameters).
Thanks a lot.
I ended up creating a File --Print... menu option that brings up the
print dialog.
One of the irritating things about the print preview dialog is that a
lot of things that you would want to change (like this particular
point) are "private" within the control and therefore not changeable. I
would have liked to have seen protected methods like
OnPrintButtonCl ick, etc, so that one could override the behaviour.
It would also have been nice to be able to hide / disable buttons on
the toolbar if we wanted to, even if the only way were to set a
PrintButtonEnab led property or something like that.
PrintPreviewDia log and TabControl are two of the hokier controls in
..NET. I hope that someday they'll revisit them and make much-needed
improvements.
Ok, so there's no way to add a new button in the toolbar I imagine ?!
"Bruce Wood" <br*******@cana da.coma écrit dans le message de news: 11************* ********@h54g20 00...legro ups.com...
>
choupi wrote:
>Hello,
Is there a way to call a printDialog from a printPreviewDia log (from print icon for example)? Indeed, the print icon in the printpreviewdia log prints directly the document without lunching the printdialog (i.e. the user can't choose the print parameters).
Thanks a lot.
I ended up creating a File --Print... menu option that brings up the
print dialog.
One of the irritating things about the print preview dialog is that a
lot of things that you would want to change (like this particular
point) are "private" within the control and therefore not changeable. I
would have liked to have seen protected methods like
OnPrintButtonCl ick, etc, so that one could override the behaviour.
It would also have been nice to be able to hide / disable buttons on
the toolbar if we wanted to, even if the only way were to set a
PrintButtonEnab led property or something like that.
PrintPreviewDia log and TabControl are two of the hokier controls in
.NET. I hope that someday they'll revisit them and make much-needed
improvements.
Well, I just have found a simple way using Reflection, and it works
perfectly.
Let me know if you're interested.
Thanks.
We're interested!
Robin S.
---------------------------------
"choupi" <no**@none.comw rote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
Well, I just have found a simple way using Reflection, and it works
perfectly.
Let me know if you're interested.
Thanks. - using System;
-
-
using System.Reflection;
-
-
using System.Drawing;
-
-
using System.Drawing.Printing;
-
-
using System.Windows.Forms;
-
-
namespace Test
-
-
{
-
-
public class MyPrintPreviewDialog : System.Windows.Forms.PrintPreviewDialog
-
-
{
-
-
private ToolBarButton myPrintButton;
-
-
public MyPrintPreviewDialog() : base()
-
-
{
-
-
Type t = typeof(PrintPreviewDialog);
-
-
FieldInfo fi = t.GetField("toolBar1", BindingFlags.Instance |
-
BindingFlags.NonPublic);
-
-
FieldInfo fi2 = t.GetField("printButton", BindingFlags.Instance |
-
BindingFlags.NonPublic);
-
-
ToolBar toolBar1 = (ToolBar)fi.GetValue(this);
-
-
ToolBarButton printButton = (ToolBarButton)fi2.GetValue(this);
-
-
-
printButton.Visible = false;
-
-
-
myPrintButton = new ToolBarButton();
-
-
myPrintButton.ToolTipText = printButton.ToolTipText;
-
-
myPrintButton.ImageIndex = 0;
-
-
-
ToolBarButton[] oldButtons = new ToolBarButton[toolBar1.Buttons.Count-1];
-
-
for(int i = 0 ; i < oldButtons.Length ; i++) oldButtons[i] =
-
toolBar1.Buttons[i+1];
-
-
-
toolBar1.Buttons.Clear();
-
-
toolBar1.Buttons.Add(myPrintButton);
-
-
for(int i = 0 ; i < oldButtons.Length ; i++)
-
toolBar1.Buttons.Add(oldButtons[i]);
-
-
toolBar1.ButtonClick += new ToolBarButtonClickEventHandler(toolBar1_Click);
-
-
}
-
-
private void toolBar1_Click(object sender, ToolBarButtonClickEventArgs
-
eventargs)
-
-
{
-
-
if (eventargs.Button == myPrintButton)
-
-
{
-
-
PrintDialog printDialog1 = new PrintDialog();
-
-
printDialog1.Document = this.Document;
-
-
if (printDialog1.ShowDialog() == DialogResult.OK) this.Document.Print();
-
-
}
-
-
}
-
-
}
-
-
}
-
-
-
Thanks!
Robin S.
"choupi" <no**@none.comw rote in message
news:uW******** ******@TK2MSFTN GP02.phx.gbl...[quote]
thats quite interesting!!!
Thanks
-Srinivas.
choupi wrote:
Hello,
Is there a way to call a printDialog from a printPreviewDia log (from print
icon for example)?
Indeed, the print icon in the printpreviewdia log prints directly the
document without lunching the printdialog (i.e. the user can't choose the
print parameters).
Thanks a lot.
Thanks for the starting place for the code needed to add the
PrintDialog to PrintPreviewDia log. However, I came across a number of
issues when I tried to implement your code in VS2005 (did you write
your version under VS2003? Just curious...). Here is code that works
under VS2005: - public class MyPrintPreviewDialog :
-
System.Windows.Forms.PrintPreviewDialog
-
{
-
private ToolStripButton myPrintButton;
-
public MyPrintPreviewDialog ( ) : base ( )
-
{
-
Type t = typeof ( PrintPreviewDialog );
-
FieldInfo fi = t.GetField ( "toolStrip1",
-
BindingFlags.Instance | BindingFlags.NonPublic );
-
FieldInfo fi2 = t.GetField ( "printToolStripButton",
-
BindingFlags.Instance | BindingFlags.NonPublic );
-
ToolStrip toolStrip1 =
-
( ToolStrip ) fi.GetValue ( this );
-
ToolStripButton printButton =
-
( ToolStripButton ) fi2.GetValue ( this );
-
printButton.Visible = false;
-
myPrintButton = new ToolStripButton ( );
-
myPrintButton.ToolTipText = printButton.ToolTipText;
-
myPrintButton.ImageIndex = 0;
-
-
ToolStripItem [ ] oldButtons =
-
new ToolStripItem [ toolStrip1.Items.Count ];
-
for ( int i = 0; i < oldButtons.Length; i++ )
-
oldButtons [ i ] = toolStrip1.Items [ i ];
-
-
toolStrip1.Items.Clear ( );
-
toolStrip1.Items.Add ( myPrintButton );
-
for ( int i = 0; i < oldButtons.Length; i++ )
-
toolStrip1.Items.Add ( oldButtons [ i ] );
-
toolStrip1.ItemClicked +=
-
new ToolStripItemClickedEventHandler ( toolBar1_Click );
-
}
-
-
private void toolBar1_Click ( object sender,
-
ToolStripItemClickedEventArgs eventargs )
-
{
-
if ( eventargs.ClickedItem == myPrintButton )
-
{
-
PrintDialog printDialog1 = new PrintDialog ( );
-
printDialog1.Document = this.Document;
-
if ( printDialog1.ShowDialog ( ) == DialogResult.OK )
-
this.Document.Print ( );
-
}
-
}
-
}
Thanks again for your inspiration.
Thx!! this was very useful ! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael A. Covington |
last post by:
By default, my PrintPreviewDialog is coming out too small. What is the best
way to control its size and position? Ideally, I'd just like to maximize
it. Thanks!
|
by: Harry J. Smith |
last post by:
I am using the PrintPreviewDialog Window Form from the Toolbox.
It displays my RichTextBox contents correctly, but when I click on the Print
icon on this form it prints one blank page and no text.
How can I fix this to print the text that is being displayed?
Here is the code I use to bring up the form:
string stringText = helpTextOut.Text;
|
by: Steph. |
last post by:
Hi,
Is there a BUG in the printdialog ? When I create a PrintDialog ans set the "DefaultPageSettings.Landscape" property to "false" and then display the dialog, select "Landscape" and click OK, the value of the "DefaultPageSettings.Landscape" is still false !!??
Code Exemple :
PrintDialog PDialog = new PrintDialog();
PDialog.PrinterSettings = new System.Drawing.Printing.PrinterSettings();...
|
by: Blaine |
last post by:
When I show my Windows Form as a dialog box (ShowDialog(Me)) and click on a
button that calls the ShowDialog of either the PageSetupDialog or PrintDialog
conrtol, my Windows Form closes After I close the PageSetupDialog or
PrintDialog. This doesn't happen if the Windows Form is displayed using the
Show method.
Does anyone have a solution?
I've made my own Print Setup Dialog Box (frmPrint). I've added the
PrintDocument, PageSetupDialog...
|
by: Franlin W |
last post by:
Is it possible to print directly to file without PrintDialog or
PrintPreviewDialog?
Have any succeeded to program this feature?
Cheers,
| |
by: Richard MSL |
last post by:
I am using PrintPreviewDialog to preview a file. There is a button that the
user can press, which seems to print the file to the default printer. I would
like to capture a click on that button so that I can present a PrintDialog,
print some files in a special way, etc. But there does not seem to be an
event among the PrintPreviewDialog members to do this? Or perhaps I missed
it? I would appreciate any suggestions. Thanks.
|
by: Spitaki |
last post by:
Hi,
When I call the sub Print the PrintDialog opens twice. What do I have to change so this won't happen again? When I call the sub PrintPreview it works just fine. Has anyone an idea what I do wrong?
Thanks in advance for your help.
Public Sub Print()
Try
Dim dlgPrint As New PrintDialog()
|
by: sunny123 |
last post by:
How Can i set the print icon in the printpreviewdialog to go to the
printdialog?
when I click on Report button in my application it'll open the report in print preview screen. There when I click the print icon it will directly send the report to the printer. Before report send to the printer i want to give the option for selecting printer by showing print dialog.
This is very urgent please help me.
Thanks in advance
|
by: Artie |
last post by:
Hi,
I've searched the web but can't find a solution to an apparently
really simple problem.
My app contains an HTML string and I need to be able to invoke the
Print Dialog to print the HTML correctly formatted (i.e. not as raw
HTML) to a printer that the User chooses.
So, I need something like:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |