Click here to Skip to main content
15,923,845 members
Home / Discussions / C#
   

C#

 
AnswerRe: I want to open PDF File in my application Pin
Gulfraz Khan4-Aug-08 4:23
Gulfraz Khan4-Aug-08 4:23 
GeneralRe: I want to open PDF File in my application Pin
Laji594-Aug-08 18:35
Laji594-Aug-08 18:35 
Questioncapturing events at form level Pin
neer14-Aug-08 2:15
neer14-Aug-08 2:15 
AnswerRe: capturing events at form level Pin
Simon P Stevens4-Aug-08 2:21
Simon P Stevens4-Aug-08 2:21 
Questionprinting in C#.net Pin
varun_mca_ju4-Aug-08 2:01
varun_mca_ju4-Aug-08 2:01 
AnswerRe: printing in C#.net Pin
teejayem4-Aug-08 3:05
teejayem4-Aug-08 3:05 
QuestionRe: printing in C#.net Pin
varun_mca_ju5-Aug-08 0:20
varun_mca_ju5-Aug-08 0:20 
AnswerRe: printing in C#.net [modified] Pin
teejayem5-Aug-08 2:59
teejayem5-Aug-08 2: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 21:42
varun_mca_ju5-Aug-08 21:42 
QuestionC# windows application and web service Pin
farhit4-Aug-08 1:55
farhit4-Aug-08 1:55 
Questionreverse lookup in dictionary Pin
vytheese4-Aug-08 1:45
professionalvytheese4-Aug-08 1:45 
AnswerRe: reverse lookup in dictionary Pin
User 66584-Aug-08 2:12
User 66584-Aug-08 2:12 
GeneralRe: reverse lookup in dictionary Pin
vytheese4-Aug-08 2:19
professionalvytheese4-Aug-08 2:19 
GeneralRe: reverse lookup in dictionary Pin
User 66584-Aug-08 2:25
User 66584-Aug-08 2:25 
GeneralRe: reverse lookup in dictionary Pin
vytheese4-Aug-08 2:41
professionalvytheese4-Aug-08 2:41 
GeneralRe: reverse lookup in dictionary Pin
Brady Kelly4-Aug-08 2:45
Brady Kelly4-Aug-08 2:45 
GeneralRe: reverse lookup in dictionary Pin
vytheese4-Aug-08 3:00
professionalvytheese4-Aug-08 3:00 
GeneralRe: reverse lookup in dictionary Pin
leppie4-Aug-08 3:24
leppie4-Aug-08 3:24 
AnswerRe: reverse lookup in dictionary Pin
PIEBALDconsult4-Aug-08 13:53
mvePIEBALDconsult4-Aug-08 13:53 
Question.Tex files and word equations Pin
chrisha844-Aug-08 1:18
chrisha844-Aug-08 1:18 
Questionwhy we use CaspolSecurityPolicyCreator.cs Class Pin
wasimsharp4-Aug-08 1:16
wasimsharp4-Aug-08 1:16 
AnswerRe: why we use CaspolSecurityPolicyCreator.cs Class Pin
Ashfield4-Aug-08 1:31
Ashfield4-Aug-08 1:31 
QuestionSilly question - bool initialization in C# Pin
Mohammad A Gdeisat4-Aug-08 1:03
Mohammad A Gdeisat4-Aug-08 1:03 
AnswerRe: Silly question - bool initialization in C# Pin
wasimsharp4-Aug-08 1:13
wasimsharp4-Aug-08 1:13 
GeneralRe: Silly question - bool initialization in C# Pin
Mohammad A Gdeisat4-Aug-08 1:16
Mohammad A Gdeisat4-Aug-08 1: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.