473,386 Members | 1,621 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,386 software developers and data experts.

PrintDialog and UserControl

Hi,

I wrote a userControl w/ a toolbar.

One button is supposed to open the PrintDialog. When I use the control
in a different project and click that button - the form simply closes
and the application continues working?

Any suggestions why this behavour occures??

Martin
##SNIPPET##

private void toolBar1_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
switch(toolBar1.Buttons.IndexOf(e.Button))
{
case 0: // Printer Selection
try
{
MessageBox.Show(this, "000");
PrintDialog pd = new PrintDialog();

pd.Document = printPreviewControl1.Document;

if(pd.ShowDialog()==DialogResult.OK)
{
printPreviewControl1.Document.PrinterSettings = pd.PrinterSettings;
}
pd.Dispose();
}
catch(Exception ex)
{
MessageBox.Show(this, "Source:\n"+ex.Message+"\nSource:\n"+ex.Source );
}
break;
Nov 16 '05 #1
1 3857
Sorry,

my mistake had no PrintDocument in the Preview ;-) (Doh!)

Martin

mphanke wrote:
Hi,

I wrote a userControl w/ a toolbar.

One button is supposed to open the PrintDialog. When I use the control
in a different project and click that button - the form simply closes
and the application continues working?

Any suggestions why this behavour occures??

Martin
##SNIPPET##

private void toolBar1_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
switch(toolBar1.Buttons.IndexOf(e.Button))
{
case 0: // Printer Selection
try
{
MessageBox.Show(this, "000");
PrintDialog pd = new PrintDialog();

pd.Document = printPreviewControl1.Document;

if(pd.ShowDialog()==DialogResult.OK)
{

printPreviewControl1.Document.PrinterSettings = pd.PrinterSettings;
}
pd.Dispose();
}
catch(Exception ex)
{
MessageBox.Show(this,
"Source:\n"+ex.Message+"\nSource:\n"+ex.Source );
}
break;

Nov 16 '05 #2

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

Similar topics

2
by: aimee | last post by:
Hi. Is there a way to capture the events fired in a PrintDialog? I would like to capture when the user presses "Print" so I can do some cleanup. The asp.net (IE6) application I'm working on has 6...
3
by: John O'Neill | last post by:
Hi In C# I would like to be able to set the printer device for printing a document without using the PrintDialog. I am writing a pocket pc application which uses a web service to print. I can...
2
by: David | last post by:
Does anybody know how to check the AllowSelection radio button in the PrintDialog Dialog? I want to set this to checked if the user has selected a subset of text.
4
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,...
1
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...
0
by: Nícolas Rodrigo Santana | last post by:
I am working in an application where I use the Visio Screen, come of: "AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl" Everything this functioning correctly, but when I print this not...
4
by: mafandon | last post by:
Is it possible to send a performclick to a button on a printdialog? I know you can do an if statement similar to: if windows.forms.dialogresult.cancel then msgbox("User cancelled print...
10
by: choupi | last post by:
Hello, Is there a way to call a printDialog from a printPreviewDialog (from print icon for example)? Indeed, the print icon in the printpreviewdialog prints directly the document without...
2
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...
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:
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
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,...

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.