Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

c# print specific text with underline

$
0
0

I want to print some text like this.

This is how i want to print the text.

the code i am using is

privatevoid button3_Click(object sender,EventArgs e){
        stringToPrint ="This is how i want to print the text";
        printFont =newFont("Times New Roman",10);
        pd.PrintPage+=newPrintPageEventHandler(pd_PrintPage);try{
            pd.Print();}catch(Exception e){}}void pd_PrintPage(object sender,PrintPageEventArgs ev){int charactersOnPage =0;int linesPerPage =0;

        ev.Graphics.MeasureString(stringToPrint, printFont,
            ev.MarginBounds.Size,StringFormat.GenericTypographic,out charactersOnPage,out linesPerPage);

        ev.Graphics.DrawString(stringToPrint, printFont,Brushes.Black,
            ev.MarginBounds,StringFormat.GenericTypographic);

        stringToPrint = stringToPrint.Substring(charactersOnPage);

        ev.HasMorePages=(stringToPrint.Length>0);}

I want to change the Font from regular to an Underline for some specific words in the string.

And if there is another Better way to do this job then please tell me i'll change my code. Please Help me Out! :)


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>