當前位置:編程學習大全網 - 遊戲軟體 - 如何:在 Windows 窗體上繪制垂直文本

如何:在 Windows 窗體上繪制垂直文本

下面的代碼示例演示如何使用DrawString方法Graphics窗體上繪制文本。 或者,可以使用TextRenderer窗體上繪制文本。 有關詳細信息,請參閱如何: 用 GDI 繪制文本。

示例

C#復制

public void DrawString(){

System.Drawing.Graphics formGraphics = this.CreateGraphics(); string drawString = "Sample Text";

System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16);

System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); float x = 150.0F; float y = 50.0F;

System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();

formGraphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);

drawFont.Dispose();

drawBrush.Dispose();

formGraphics.Dispose();

}

  • 上一篇:最弱無敗神裝機龍《巴哈姆特》的劇情簡介
  • 下一篇:wisml什麽意思?
  • copyright 2024編程學習大全網