次のコードのように実行時にフォント サイズを変更しようとしましたが、常にStackOverflowException
.
protected override void OnResize(EventArgs e)
{
this.bitmapDoubleBuffer = new Bitmap(base.Width, base.Height);
this.backGraphics = Graphics.FromImage(this.bitmapDoubleBuffer);
}
public void ReDrawRuntime()
{
SizeF sizeF = this.backGraphics.MeasureString(this.Text, this.Font);
if (sizeF.Width > this.Size.Width)
{
this.Font = new Font(this.Font.Name, 20, this.Font.Style);
sizeF = this.backGraphics.MeasureString(this.Text, this.Font);
}
this.backGraphics.DrawString(this.Text,
this.Font,
this.solidBrushForeColor,
(float)((int)width),
(float)((int)height));
this.graphicsDoubleBuffer.DrawImage(this.bitmapDoubleBuffer, 0, 0);
}