Israel

Israel

  • 701
  • 1.3k
  • 217.2k

Its cant print singly...

Sep 7 2016 7:27 AM
Hi!
 
With theses codes I can print all the textboxes content without problems.
Then what can I do if I would like to print for example a specific texbox or some textboxes (not all for instance).
 
See codes please:
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString(textBox1.Text, textBox1.Font, Brushes.Black, 50, 20);
e.Graphics.DrawString(textBox2.Text, textBox2.Font, Brushes.Black, 50, 50);
e.Graphics.PageUnit = GraphicsUnit.Inch;
}
private void button1_Click(object sender, EventArgs e)
{
printDialog1.Document = printDocument1;
if (printDialog1.ShowDialog() == DialogResult.OK)
{
printDocument1.Print();
}
private void Printpreview_Click(object sender, EventArgs e)
{
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.ShowDialog();
}
 
Thanx in advance,
Israel. 

Answers (4)