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