TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Amit Alagh
NA
1
935
how to print data using windows form and save it
Nov 3 2015 4:15 AM
I am working on a project usin c#.I want to develop a code to print data from the text boxes. Currently I have a code but that is just printing the data from one text box.Kindly tell me how to save it also with the same click.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.Threading;
namespace printform
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int t = 0;
private void button1_Click(object sender, EventArgs e)
{
try
{
PrintDocument pd = new PrintDocument();
pd.DefaultPageSettings.PaperSize = new PaperSize("A4", 827, 1170);
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
pd.Print();
}
catch (Exception ex)
{
MessageBox.Show("an error", ex.ToString());
}
}
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
if (t < 2)
{
//ev.Graphics.DrawString(.ToString(), new Font("Times New Roman", 14, FontStyle.Bold), Brushes.Black, 20, 100);
ev.Graphics.DrawString(textName.Text.ToString(), new Font("Times New Roman", 14, FontStyle.Bold), Brushes.Black, 20, 100);
ev.Graphics.DrawString(textSname.Text.ToString(), new Font("Times New Roman", 14, FontStyle.Bold), Brushes.Black, 20, 100);
t++;
if (t < 2)
{
ev.HasMorePages = true;
}
else
{
ev.HasMorePages = false;
}
}
}
}
}
Reply
Answers (
1
)
Compare Single Listbox
about whatsapp