免費論壇 繁體 | 簡體
Sclub交友聊天~加入聊天室當版主
分享
返回列表 回復 發帖

畫布

form上放一個PictureBox及2個button!

可正常顯示呀!


Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        DrawInPictureBox("星期1")
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        DrawInPictureBox("亂馬客")
End Sub

Private Sub DrawInPictureBox(ByVal drawString As String)

        Dim drawfont As New Font("Helvetica", 16, FontStyle.Bold) '定義字型
        Dim x = 5, y = 9 '定義字體左上角位置
        Dim mycolor1 As New SolidBrush(Color.FromArgb(25, 25, 25))    '定義字體顏色

        Dim g As Graphics

        ' 根據 PictureBox 控制項建立一個 Graphics 物件並清除其內容。
        g = PictureBox1.CreateGraphics()
        g.Clear(Color.White)
        g.DrawString(drawstring, drawfont, mycolor1, x, y)
End Sub
返回列表