Vaish

Hi

I have 'PrintPreviewDialog1' in my windows application. This print preview dialog will be populated from the main form. So the default control of the PrintPreviewDialog has print ,zoom etc.

My question: How do I edit this control programaticaly to add save button I am tring to save the previewed document as PDF.

Advance Thanks

Vaish




Re: Windows Forms General How to add save button to PrintPreviewDialog? VB.Net or VS 2005

Zhi-Xin Ye - MSFT

It's not easy to add save button to printPreviewDialog, but to save file, why not using SaveFileDialog




Re: Windows Forms General How to add save button to PrintPreviewDialog? VB.Net or VS 2005

Vaish

Hi

Thanks for reply.

The reason I am using Print previewdialog, when user click the button the preview open the document populated from main form.

If I use savedialog can I populate the data from the main form . If yes could you please show some code.

Thank you






Re: Windows Forms General How to add save button to PrintPreviewDialog? VB.Net or VS 2005

Zhi-Xin Ye - MSFT

Of course you can, have a read at this topic:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.savefiledialog.aspx




Re: Windows Forms General How to add save button to PrintPreviewDialog? VB.Net or VS 2005

Karthik Krishnaswami

Add this to your project,use this instead of the conventional PrintPreviewDialog

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using System.Reflection;

/// <summary>

/// Summary description for MyPrintPreviewDialog.

/// </summary>

public class MyPrintPreviewDialog : PrintPreviewDialog

{

public MyPrintPreviewDialog()

{

Button btn = Controls[1].Controls[2]as Button;

//Get left and top

int x = btn.Left + btn.Width+10;

Button save = new Button();

save.FlatStyle = FlatStyle.Popup;

Controls[1].Controls.Add(save);

save.Left = x;

save.Width = btn.Width;

save.Text = "Save";

save.Click +=new EventHandler(save_Click);

}

private void save_Click(object sender, EventArgs e)

{

MessageBox.Show("save");

}

}

Hope this helps!





Re: Windows Forms General How to add save button to PrintPreviewDialog? VB.Net or VS 2005

Vaish

Hi Guys

Thanks a lot for your help. That was very very helpful.

Vaish