0
votes

I created an app with VS2017 C# WinForms, created a report for a table inside with RDLC reportviewer, the report is working well, I want to print this report directly and send it to the printer without popping up print preview dialog.

Please be informed that I googled this issue and searched this site as well and I couldn't find a solution.

Tried to use the MSDN topic (Walkthrough: Printing a Local Report without Preview) but still no luck.

Here is my button which runs several queries including opening a form (voucher) containing an rdlc reportviewer which loads data to show up in the report:

private void button12_Click(object sender, EventArgs e)
        {
            SoundPlayer player = new SoundPlayer(Properties.Resources.switch_8);
            player.Play();

            if (string.IsNullOrWhiteSpace(textBox1.Text) || textBox1.Text == "0")
            {

                MessageBox.Show("Please select an item!");


            }
            else
            {
                MOVE_TO_SOLD();
                UPDATE_RECEIPT();
                LOAD_DATA();


                CLEAR_TEMP();
                CHECK_FOR_REC_ID();
                GET_NEW_REC_ID();
                LOAD_DATA();
                txtdiscount.Text = "0";
                textBox5.Text = "0";
                recowner.Text = recnum.Text;
                voucher vr = new voucher();
                vr.ShowDialog();

            }


        }

Thank You!

1
Instead of using .ShowPrintPreviewDialog();, You can use .Print(); directly.Shady Boshra
Could you please make it more clear to me ? Thanks !Awder Mirza
To let me be more helpful, please add some codes that we can detect what you have to do.Shady Boshra
I did edit the question, please see itAwder Mirza

1 Answers

0
votes

This Walkthrough will be very helpful for your problem. Please check it out, and if this answer was helpful, mark it as an answer.