Click here to Skip to main content
14,766,867 members
Home » Discussions » C#
   

C#

 
AnswerRe: I want to open PDF File in my application Pin
Gulfraz Khan4-Aug-08 5:23
MemberGulfraz Khan4-Aug-08 5:23 
GeneralRe: I want to open PDF File in my application Pin
Laji594-Aug-08 19:35
MemberLaji594-Aug-08 19:35 
Questioncapturing events at form level Pin
neer14-Aug-08 3:15
Memberneer14-Aug-08 3:15 
AnswerRe: capturing events at form level Pin
Simon P Stevens4-Aug-08 3:21
MemberSimon P Stevens4-Aug-08 3:21 
Questionprinting in C#.net Pin
varun_mca_ju4-Aug-08 3:01
Membervarun_mca_ju4-Aug-08 3:01 
AnswerRe: printing in C#.net Pin
teejayem4-Aug-08 4:05
Memberteejayem4-Aug-08 4:05 
QuestionRe: printing in C#.net Pin
varun_mca_ju5-Aug-08 1:20
Membervarun_mca_ju5-Aug-08 1:20 
AnswerRe: printing in C#.net [modified] Pin
teejayem5-Aug-08 3:59
Memberteejayem5-Aug-08 3:59 
The example just shows the use of a StreamReader; However, it can be what ever type you want it to be (as long as you can get it as a string come time to print). You need a member variable for your data and in the "private void pd_PrintPage(object sender, PrintPageEventArgs ev)" (in the example) you loop through your data and print it accordingly.


EDIT:

Here is a quick example of what you want to do (i think). Here[^] is the image of the form. Here[^] is the image of the output. Below is the code. Please let me know if this is what you need. NOTE: there still needs more work done in the print event handler (like counting the lines for page breaks).

public Form1()
        {
            InitializeComponent();

            printDocument1.PrintPage += printDocument1_PrintPage;
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {
            using (PrintDialog pd = new PrintDialog())
            {
                if (pd.ShowDialog() == DialogResult.OK)
                {
                    printDocument1.PrinterSettings = pd.PrinterSettings;

                    printDocument1.Print();
                }
            }
        }

        void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Font objFont = new Font("Tahoma", 8.5F);
            float fTopMargin = e.MarginBounds.Top;
            float fLeftMargin = 50;
            float fRightMargin = e.MarginBounds.Right - 150;


            string Name = String.Concat("Name: ", txtName.Text);
            string PhoneNumber = String.Concat("Phone Number: ", txtPhoneNum.Text);
            string Email = String.Concat("Email Address: ", txtEmail.Text);
            string DateOfBirth = String.Concat("Date Of Birth: ", txtDateOfBirth.Text);

            e.Graphics.DrawString(Name, objFont, Brushes.Black, fLeftMargin, fTopMargin);
            e.Graphics.DrawString(PhoneNumber, objFont, Brushes.Black, fRightMargin - PhoneNumber.Length, fTopMargin);

            fTopMargin += objFont.GetHeight() * 2; // Skip 2 lines

            e.Graphics.DrawString(Email, objFont, Brushes.Black, fLeftMargin, fTopMargin);

            fTopMargin += objFont.GetHeight(); //skip one more line

            e.Graphics.DrawString(DateOfBirth, objFont, Brushes.Black, fLeftMargin, fTopMargin);



            objFont.Dispose();
            e.HasMorePages = false;
        }


Don't be overcome by evil, but overcome evil with good

modified on Tuesday, August 5, 2008 9:47 AM

GeneralRe: printing in C#.net...IT WORKS LIKE A CHARM Pin
varun_mca_ju5-Aug-08 22:42
Membervarun_mca_ju5-Aug-08 22:42 
QuestionC# windows application and web service Pin
farhit4-Aug-08 2:55
Memberfarhit4-Aug-08 2:55 
Questionreverse lookup in dictionary Pin
vytheese4-Aug-08 2:45
professionalvytheese4-Aug-08 2:45 
AnswerRe: reverse lookup in dictionary Pin
User 66584-Aug-08 3:12
MemberUser 66584-Aug-08 3:12 
GeneralRe: reverse lookup in dictionary Pin
vytheese4-Aug-08 3:19
professionalvytheese4-Aug-08 3:19 
GeneralRe: reverse lookup in dictionary Pin
User 66584-Aug-08 3:25
MemberUser 66584-Aug-08 3:25 
GeneralRe: reverse lookup in dictionary Pin
vytheese4-Aug-08 3:41
professionalvytheese4-Aug-08 3:41 
GeneralRe: reverse lookup in dictionary Pin
Brady Kelly4-Aug-08 3:45
MemberBrady Kelly4-Aug-08 3:45 
GeneralRe: reverse lookup in dictionary Pin
vytheese4-Aug-08 4:00
professionalvytheese4-Aug-08 4:00 
GeneralRe: reverse lookup in dictionary Pin
leppie4-Aug-08 4:24
Memberleppie4-Aug-08 4:24 
AnswerRe: reverse lookup in dictionary Pin
PIEBALDconsult4-Aug-08 14:53
professionalPIEBALDconsult4-Aug-08 14:53 
Question.Tex files and word equations Pin
chrisha844-Aug-08 2:18
Memberchrisha844-Aug-08 2:18 
Questionwhy we use CaspolSecurityPolicyCreator.cs Class Pin
wasimsharp4-Aug-08 2:16
Memberwasimsharp4-Aug-08 2:16 
AnswerRe: why we use CaspolSecurityPolicyCreator.cs Class Pin
Ashfield4-Aug-08 2:31
MemberAshfield4-Aug-08 2:31 
QuestionSilly question - bool initialization in C# Pin
Mohammad A Gdeisat4-Aug-08 2:03
MemberMohammad A Gdeisat4-Aug-08 2:03 
AnswerRe: Silly question - bool initialization in C# Pin
wasimsharp4-Aug-08 2:13
Memberwasimsharp4-Aug-08 2:13 
GeneralRe: Silly question - bool initialization in C# Pin
Mohammad A Gdeisat4-Aug-08 2:16
MemberMohammad A Gdeisat4-Aug-08 2:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.