Noah,
Give this a shot. Just set the size of the label to the size of the form in
the forms resize event. Used it for a similar problem. I think it's based
on some samples from Petzold's Programming MS Windows with C#
Enjoy,
-Robert
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2d;
namespace exp
{
public class ExpandoLabel : Label
{
public ExpandoLabel()
{
}
protected override void OnPaint( PaintEventArgs e )
{
GraphicsPath path;
RectangleF rectfBounds, rectfTemp;
if( this.Text == "" )
{
Console.WriteLine( "null string in paint" );
return;
};
path = new GraphicsPath();
path.AddString( "Ty", this.Font.FontFamily, (int)
this.Font.Style, 100,
new Point( 0, 0 ), new
StringFormat() );
rectfTemp = path.GetBounds();
path = new GraphicsPath();
path.AddString( this.Text, this.Font.FontFamily, (int)
this.Font.Style, 100,
new Point( 0, 0 ), new
StringFormat() );
rectfBounds = path.GetBounds();
rectfBounds.Height = rectfTemp.Height;
PointF[] aptfDest = { new PointF( 0, 0 ),
new PointF( this.Width, 0 ),
new PointF( 0,
this.Height ) };
e.Graphics.Transform = new Matrix( rectfBounds, aptfDest );
e.Graphics.SetClip( path );
e.Graphics.FillPath( new SolidBrush( this.ForeColor ), path );
}
}
}