扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
在灯塔等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供做网站、网站设计 网站设计制作定制制作,公司网站建设,企业网站建设,品牌网站制作,成都营销网站建设,成都外贸网站建设,灯塔网站建设费用合理。
Dim nBrush As New SolidBrush(Color.Red)
Dim font As New Font("宋体", 12)
Dim bmp As Bitmap = Bitmap.FromFile("c:\123.jpg")
Dim info As String = "完成"
Dim g As Graphics = Graphics.FromImage(bmp)
Dim sizef As SizeF = g.MeasureString(info, font)
Dim left As Single = (PictureBox1.Width - sizef.Width) / 2
Dim top As Single = (PictureBox1.Height - sizef.Height) / 2
g.DrawString(info, font, nBrush, left, top)
g = PictureBox1.CreateGraphics
g.DrawImage(bmp, 0, 0)
g = Nothing
bmp = Nothing
End Sub
VB.NET在PicTureBox控件里显示文本,似乎并不简单,试试这段代码,自己琢磨一下:
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim format1 As New StringFormat(StringFormatFlags.NoClip) '封装文本布局信息(如对齐、文字方向和 Tab 停靠位)
format1.LineAlignment = StringAlignment.Center '垂直居中
format1.Alignment = StringAlignment.Center '水平居中
Dim MyFont As New Font("宋体", 12, FontStyle.Regular)
Dim displayRectangle As New Rectangle() '存储一组整数,共四个,表示一个矩形的位置和大小
displayRectangle = New Rectangle(New Point(20, 20), New Size(200, 100))
e.Graphics.DrawString("欢迎使用VB Net", MyFont, Brushes.Black, RectangleF.op_Implicit(displayRectangle), format1) '显示单元格里的文本
End Sub
你可以在窗体上放一个lable控件,取名叫lable1,
那么实现方式就是:
private
sub
form_load()
lable1.text="今天天气很好";
end
sub
你可以试试
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim font As New Font("宋体", 16)
Dim g = PictureBox1.CreateGraphics
Dim str As String = "a001"
Dim x As Integer = (PictureBox1.Size.Width - g.MeasureString(str, font).Width) / 2 '文字居中
Dim y As Integer = 0
Dim nBrush As New SolidBrush(Color.Turquoise)
g.FillRectangle(nBrush, 0, 0, PictureBox1.Size.Width, g.MeasureString(str, font).Height)
nBrush = New SolidBrush(Color.Red)
g.DrawString(str, font, nBrush, x, y)
g = Nothing
End Sub
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流