C# Progress Bar coding exception

I was looking to add a percentage to my progress bar and was sent this link:
http://csharphelper.com/blog/2016/07/display-text-progressbar-c/

All is fine with the code below with the exception of

            e.Graphics.TextRenderingHint =
                TextRenderingHint.AntiAliasGridFit;

I get the message "The name 'TextRenderingHint' does not exist in the current context  

How do I correct this?

=============================================================================================================================

        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            // Clear the background.
            e.Graphics.Clear(pictureBox1.BackColor);

            // Draw the progress bar.
            float fraction =
                (float)(ProgressValue - ProgressMinimum) /
                (ProgressMaximum - ProgressMinimum);
            int wid = (int)(fraction * pictureBox1.ClientSize.Width);
            e.Graphics.FillRectangle(
                Brushes.LightGreen, 0, 0, wid,
                pictureBox1.ClientSize.Height);

            // Draw the text.
            e.Graphics.TextRenderingHint =
                TextRenderingHint.AntiAliasGridFit;
            using (StringFormat sf = new StringFormat())
            {
                sf.Alignment = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                int percent = (int)(fraction * 100);
                e.Graphics.DrawString(
                    percent.ToString() + "%",
                    this.Font, Brushes.Black,
                    pictureBox1.ClientRectangle, sf);
            }
        }
rwheeler23Asked:
Who is Participating?
 
David Johnson, CD, MVPConnect With a Mentor OwnerCommented:
I commented out that line and it didn't seem to affect the program
0
 
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
That is a member of the System.Drawing namespace so try adding
using System.Drawing; at the top of the file that class is in
0
 
rwheeler23Author Commented:
System.Drawing was already there and I did comment it out and tested and it works so I will simply leave it out.
0
 
rwheeler23Author Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.