Resolved Setting drawstring color from fontdialog

Runescope

Well-known member
Joined
Jan 6, 2011
Messages
53
Programming Experience
Beginner
Greetings!

I have text that I am trying to print and while I can get the font that is displayed from the font dialog quite easily, when I try and grab the colour it won't let me do it as the color in e.Graphics.DrawString is set using a brush, and the font dialog returns a color.

I'm transitioning (painfully) from VB6 to VB.NET 2010 so you might have to explain this to me like I'm a 5 year old ;)

Thanks for any help you can give!

Edit:
I believe I have solved it.

VB.NET:
        Dim drawFont As Font, drawColour As Color
        drawFont = FontDialog1.Font
        drawColour = FontDialog1.Color
        Dim drawBrush As New SolidBrush(drawColour)
        e.Graphics.DrawString("This is sample text left aligned", drawFont, drawBrush, 300, 0, LAlign)
 
Last edited:

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,346
Location
Sydney, Australia
Programming Experience
10+
Could you please post your solution so others who have the same problem might benefit from it? Also, if you haven't done it the best way, others may be able to help you do it better.
 
Top Bottom