[Go] C # to draw a report using the Graphics.DrawString method

Source: Internet
Author: User

Original Graphics.DrawString method

Draws the specified text string in the specified position and with the specified Brush and Font object.

void DrawString (string S,font font,brush Brush,float x,float y)


An example on MSDN:
public void Drawstringfloat (PaintEventArgs e) {//Create string to draw. String drawstring = "Sample Text"; Create font and brush. Font drawfont = new Font ("Arial", 16); SolidBrush Drawbrush = new SolidBrush (color.black);//Create point for Upper-left corner of drawing. float x = 150.0F; Float y = 150.0f;//Draw string to Screen.e.graphics.drawstring (drawstring, Drawfont, Drawbrush, x, y);}

Examples of applications:
          private void Myprintpage1 (Graphics formgraphics, int w, int h) {Pen mypen = new Pen (Color.fro            Margb (255, Color.Black), 1.0F);            Font MyFont1 = new Font ("Arial", "FontStyle.Bold");            Font MyFont2 = new Font ("Arial", ten, FontStyle.Bold);            Formgraphics.translatetransform (100.0F, 50.0F); Draw a horizontal line//Draw a table vertical bar for (int i = n; i <; i + =) {Formgraphics.dra                Wline (Mypen, New Point (0, I), new point (+, i)); Formgraphics.drawline (Mypen,)} for (int i = 0; i <; i + =) {fo            Rmgraphics.drawline (Mypen, New Point (I, N), new Point (I, 350));            }//Draw table Slash formgraphics.drawline (Mypen, New Point (0, $), new Point (150, 250));            Formgraphics.drawline (Mypen, New Point (a), new Point (300, 125)); Formgraphics.drawline (Mypen, New Point (175), New Point (300, 175)); Write Formgraphics.drawstring ("---Data Report---", New Font ("Arial", 10, FontStyle.Bold), Brushes.dimgray, 100,            );            Formgraphics.drawstring ("Test Date: _______________", MyFont1, Brushes.dimgray, 0, 50);            Formgraphics.drawstring ("operator (Operator): _______________", MyFont1, Brushes.dimgray, 0, 75);            Formgraphics.drawstring ("Specimen type (Parts type): _______________", MyFont1, Brushes.dimgray, 330, 50);            Formgraphics.drawstring ("Specimen number (Parts No): _______________", MyFont1, Brushes.dimgray, 330, 75);            Formgraphics.drawstring ("On" (UP): _______________ ", MyFont1, Brushes.dimgray, 0, 100);                      Formgraphics.drawstring (Down): _______________, MyFont1, Brushes.dimgray, 330, 100);            Formgraphics.drawstring ("Voltage", MyFont1, Brushes.dimgray, 190, 220);            Formgraphics.drawstring ("(Forward speed)", MyFont2, Brushes.dimgray, 300, 110); Formgraphics.drawstring ("Current", MyFont1, BRUSHES.DImgray, 340, 220);            Formgraphics.drawstring ("(Backward Speed)", MyFont2, Brushes.dimgray, 455, 110);            Formgraphics.drawstring ("Standby", MyFont1, Brushes.dimgray, 490, 220);            Formgraphics.drawstring ("Test data (Date)", MyFont1, Brushes.dimgray, 0, 270);            formgraphics.drawstring ("unit", MyFont1, Brushes.dimgray, 0, 320); Formgraphics.drawstring ("operator (Operator): _______________ Examiner (Checker): _______________", MyFont1, Brushes.dimgray, 0            , 970);            Formgraphics.drawstring (DateTime.Now.ToString ("Yyyy/mm/dd"), MyFont1, Brushes.dimgray, 180, 50);            Formgraphics.drawstring (Global.temstr[0], MyFont1, Brushes.dimgray, 180, 75);            Formgraphics.drawstring (global.temstr[2], MyFont1, Brushes.dimgray, 510, 50);            Formgraphics.drawstring (Global.temstr[1], MyFont1, Brushes.dimgray, 510, 75);            Formgraphics.drawstring (Global.temstr[3], MyFont1, Brushes.dimgray, 180, 100); Formgraphics.drawstring (GloBal.temstr[4], MyFont1, Brushes.dimgray, 500, 100); Formgraphics.drawstring ("", MyFont1, Brushes.dimgray, MyFont1);//Formgraphics.drawstring ("" Es.             Dimgray, 340);//Formgraphics.drawstring ("", MyFont1, Brushes.dimgray, 490, 270);            Formgraphics.drawstring ("V", MyFont1, Brushes.dimgray, 190, 320);            Formgraphics.drawstring ("A", MyFont1, Brushes.dimgray, 340, 320); Formgraphics.drawstring ("", MyFont1, Brushes.dimgray, 490, 320);}


[Go] C # to draw a report using the Graphics.DrawString method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.