2013-08-28 126 views
1

我在一個項目上工作,因爲我使得我的窗口不透明。在該標籤文本中的一個標籤由動態設置。設置文本後顯示如下圖像。標籤中的文本以窗口形式顯示不正確

My Window Form

在於 88

是通過動態地設置文本的標籤。

和你好窩是由我作爲解決方案的一部分嘗試,但它不工作,它的代碼是在下面。

protected override void OnPaint(PaintEventArgs e) 
    { 
     base.OnPaint(e); 
     Bitmap bitmap = new Bitmap(this.Width, this.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); 
     Graphics g = Graphics.FromImage(bitmap); 
     g.Clear(Color.Empty); 
     g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; 
     g.DrawString("hello world", new Font(this.Font.FontFamily, 48), Brushes.Blue, new Point(50, 50)); 
     e.Graphics.DrawImage(bitmap, new Point(0, 0)); 
    } 

但也看起來像標籤文本。 i want label text like clear type text please help me for it.

回答

0

嘗試使用下面的代碼

e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; 
e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; 
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; 

它會影響性能

+0

它顯示爲像以前一樣的結果。 – Archit

0

關閉反鋸齒選項TextRenderingHint

g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; 
+0

謝謝但不工作:-( – Archit