Sign in to follow this  

Another C# Question (about text)

This topic is 4133 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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
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

This topic is 4133 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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