Reputation: 57
I want to show message box after user click Print, I already tried the below code, but the message box did not appear.
void printToolStripMenuItem_Click(object sender, EventArgs e)
{
PrintFile(sender, e);
}
void PrintFile(object sender, EventArgs e)
{
PrintDialog printDialog = new PrintDialog();
printDocument1.DefaultPageSettings.Landscape = true;
printDialog.Document = printDocument1;
printDialog.UseEXDialog = true;
if (DialogResult.OK == printDialog.ShowDialog())
{
printDocument1.DocumentName = "Document Page Print";
printDocument1.Print();
MessageBox.Show("Printed", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
I want to display that message box after the user click the print button like the below image:
Upvotes: 0
Views: 190
Reputation: 545
Try:
var result = printDialog.ShowDialog();
if (result == DialogResult.OK) { ... }
Upvotes: 1