Sign in to follow this  
yadango

Another C# Question (about text)

Recommended Posts

yadango    567
Hi there, In Win32, when I draw GDI text, I usually call SetTextColor, SetBkColor, SetBkMode, followed by DrawText or TextOut etc. Is there an equivalent way of rendering text in C#? The Graphics class only has the DrawString method which doesn't take a background color or a background mode. Is the only way to do this is by DllImporting the Win32 functions? Thx

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
AFAIK Graphics.MeasureString() returns a SizeF struct, which you can use to render a background with Graphics.FillRectangle(). Simple :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Look into this class:
System.Windows.Forms.TextRenderer

It has the DrawText method and it seems to do what you want

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this