Picturebox执行时直接显示文字
时间:2014-07-17 20:01 来源: 我爱IT技术网 作者:山风
要在Picturebox上显示文字,使用方式很简单。
先把Picturebox背景指定给图像,如此就依照Picturebox的背景进行写字,之后把这图像弄成画布,在上面写字即可。
最后用DrawString函数,在画布写完字后再指定给PictureBox
具体代码如下:
- Dim bmp1 = New Bitmap(PictureBox1.Width, PictureBox1.Height) '产生图像
- bmp1 = PictureBox1.BackgroundImage
- Dim g1 = Graphics.FromImage(bmp1) '生成画布
- Dim mycolor1 As New SolidBrush(Color.FromArgb(20, 20, 20)) '定义字体颜色
- g1.DrawString("机械座标", New Font("Microsoft JhengHei", 16, FontStyle.Regular), mycolor1, 5, 7) '画布写上字符串
- PictureBox1.BackgroundImage = bmp1 'PictureBox1.Image指定该图像
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
