Hello, Iam tryin to find simple code that printing the datagridview. iv'e looked over the internet (also daniweb) i was founded only looooooongs codes or codes that print white pages. Please, anyone, help! i just want to print All the data in the datagridview (without any selected rows or something like that, just ALL).

Use printDocument Control.

Add the 'Print Document' and 'Print Dialog' control to the form. Then for the PrintPage event handler of the PrintDcoument control you can use something like this:

Font f = new Font("Arial",14,FontStyle.Regular);
            Brush b = Brushes.Black;
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
                for (int j = 0; j < dataGridView1.Columns.Count; j++)
                {
                    e.Graphics.DrawString(dataGridView1(i,j) + "    ", f, b, j*5, i*5);
                }

Create another button, name it Print or whatever you like. On the Click event of that button, call the use the PrintDialog control and assign this print document object to that print dialog.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.