C#設置頁面單位和縮放的方法
更新時間:2015年06月12日 10:16:32 作者:zhuzhao
這篇文章主要介紹了C#設置頁面單位和縮放的方法,涉及C#設置頁面屬性的相關技巧,需要的朋友可以參考下
本文實例講述了C#設置頁面單位和縮放的方法。分享給大家供大家參考。具體如下:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace advanced_drawing { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Graphics g = this.CreateGraphics(); g.PageUnit = GraphicsUnit.Inch; g.PageScale = 1; Font rulerFont = new Font("MS Sams Serif", 8.25f); Pen blackPen = new Pen(Color.Black, 0.05f); float rulerFontHeight = rulerFont.GetHeight(g); RectangleF rulerRect = new RectangleF(0, 0, 6.5f, rulerFontHeight * 1.5f); g.DrawRectangle(blackPen, rulerRect.X, rulerRect.Y, rulerRect.Width, rulerRect.Height); } } }
希望本文所述對大家的C#程序設計有所幫助。
相關文章
淺析C#中數(shù)組,ArrayList與List對象的區(qū)別
在C#中,當我們想要存儲一組對象的時候,就會想到用數(shù)組,ArrayList,List這三個對象了。那么這三者到底有什么樣的區(qū)別呢2013-07-07C#中的小數(shù)和百分數(shù)計算與byte數(shù)組操作
這篇文章介紹了C#中的小數(shù)和百分數(shù)計算與byte數(shù)組操作,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-04-04