How To Make Text Transparent [Win C#]

  • Thread starter Thread starter MikeY
  • Start date Start date
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
 
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.
 
You need to provide more info?

I presume you are creating your own component control and are inheriting
from Label? Then overriding the onPaint?
 
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.
 
Back
Top