How To Make Text Transparent [Win C#]

M

MikeY

Can anyhow direct me on how to make text trasnparent. The Text is loctated
in my custom buttons. A Sample of my code is below.

Font fn = new Font("Tahoma",8, System.Drawing.FontStyle.Bold);



string str= "Sauteed Spinach & Bacon";



StringFormat sf=(StringFormat)StringFormat.GenericTypographic.Clone();

sf.Alignment=StringAlignment.Center;

sf.LineAlignment=StringAlignment.Center;

sf.Trimming=StringTrimming.EllipsisWord;



myGraphics.DrawString(str, fn, Brushes.Black,new
RectangleF(5,5,this.ClientRectangle.Width-15,this.ClientRectangle.Height-10),sf);



this.Region = new Region(myGraphicsPath);

fn.Dispose();



Thank you all in advance



MikeY
 
B

Bob Powell [MVP]

Just draw the text with a transparent brush such as
SolidBrush(Color.FromArgb,128,Color.Black))

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
D

Daniel

You need to provide more info?

I presume you are creating your own component control and are inheriting
from Label? Then overriding the onPaint?
 
M

MikeY

Thanks Bob.


Bob Powell said:
Just draw the text with a transparent brush such as
SolidBrush(Color.FromArgb,128,Color.Black))

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top