I have some white text I am putting over a very light background. Is there anyway to outline the text in black? After some googling it looks like there are some pretty complicated solutions, but I am looking for something like a check box that says "outline". Is there such a beast?

Thanks,

Dave

I have some white text I am putting over a very light background. Is there anyway to outline the text in black? After some googling it looks like there are some pretty complicated solutions, but I am looking for something like a check box that says "outline". Is there such a beast?

Thanks,

Dave

Dim grp As Graphics = Me.CreateGraphics

        Dim gp As New Drawing2D.GraphicsPath
        Dim useFont As Font = New Font("Times New Roman", 100, FontStyle.Regular)

        grp.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
        grp.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias

        gp.AddString("sample text", useFont.FontFamily, FontStyle.Regular, 100, New Point(0, 0), StringFormat.GenericTypographic)
        useFont.Dispose()

        
        grp.FillPath(Brushes.White, gp)
        If CheckBox1.Checked Then
            grp.DrawPath(Pens.Black, gp)
        End If

        gp.Dispose()
Comments
Great Code, Thanks Luc001

Hm, I made an empty project and put that code in form load (and removed the "if" for the check box). When I run it, the form is empty. Shouldn't I expect to see "sample text" on the form?

Thanks,

Dave

Ah, great, that is exactly what I was looking for. Why doesn't it work if run in form_load?

Ah, great, that is exactly what I was looking for. Why doesn't it work if run in form_load?

At Load stage of form GUI is not prepared.

If you put this code in the form Paint event instead of form Load, the desired effect is achieved.

Thanks for your help.

Dave

This question has already been answered. Start a new discussion instead.