Create Print method more easily

Asked

Viewed 119 times

0

I have a form ready and I need to check the variables in the right fields, but I want a faster and easier way to do it. Because I don’t want to waste a lot of time doing the e.Graphics.Drawstring because it takes a long time to set in the right place. Is there any hardware or even something I can first show me the x y coordinates ?

        Font fonte = new Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point);
        Font fonte2 = new Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point);


        Bitmap jpg = Properties.Resources.Form2;
        Image newImage = jpg;
        e.Graphics.DrawImage(newImage, 1, 1, newImage.Width, newImage.Height);
        e.Graphics.DrawString(txtNomePaciente.Text, fonte2, Brushes.Black, 290, 285);
        e.Graphics.DrawString(txtDtNasc.Text, fonte2, Brushes.Black, 330, 305);
        e.Graphics.DrawString(txtRgPaciente.Text, fonte2, Brushes.Black, 200, 325);
        e.Graphics.DrawString(txtNomeSolicitante.Text, fonte2, Brushes.Black, 225,            345);
        e.Graphics.DrawString(txtDtAtend.Text, fonte2, Brushes.Black, 330, 365);

        if (RbSim.Checked)
        {
            e.Graphics.DrawString("X", fonte, Brushes.Black, 260, 388);
        }
        else
            e.Graphics.DrawString("X", fonte, Brushes.Black, 600, 388);

        e.Graphics.DrawString(txtDias.Text, fonte2, Brushes.Black, 355, 385);
        e.Graphics.DrawString(CbUnid.Text, fonte2, Brushes.Black, 362, 425);
        e.Graphics.DrawString(txtTele.Text, fonte2, Brushes.Black, 337, 465);

        e.Graphics.DrawString(DateTime.Now.ToString("dd                      MMMMM                            yyyy"), fonte2, Brushes.Black, 359, 527);
        e.Graphics.DrawString(DateTime.Now.ToString("dd/MM/yyyy"), fonte2, Brushes.Black, 320, 830);
        e.Graphics.DrawString(txtNomePaciente.Text, fonte2, Brushes.Black, 320, 850);
        e.Graphics.DrawString(txtDtAtend.Text, fonte2, Brushes.Black, 330, 870);
        e.Graphics.DrawString(CbUnid.Text, fonte2, Brushes.Black, 350, 890);
        e.Graphics.DrawString(txtID, fonte2, Brushes.Black, 700, 205);
        e.Graphics.DrawString(txtID, fonte2, Brushes.Black, 700, 800);
  • Do you have any code ready that can be put in your question?

  • Thus, I can put but it would not be the point to improve the code, but rather to facilitate the creation of a form for printing

  • I know, but it’s a little abstract to understand your doubt. Having code I can direct a good answer to you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.