我一般在form 上畫線的方法
Dim grap1,grap2 As Graphics
1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
grap2 = Me.CreateGraphics
End Sub
2. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim pen1 As Pen
pen1 = New Pen(Color.Gold, 5)
grap2.DrawLine(pen1, 5, 5, 150, 150)
End Sub
現在要在picturebox畫線 不動到原圖 是要在哪宣告
我試過的方法 畫出來的線 都顯示在form 上面
我想到的方案 把圖放入bitmap 在上面畫好 在載入進去
這樣可行嗎 還是有更簡單的方法
Private Sub PictureBox1_LoadCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles PictureBox1.LoadCompleted
grap1 = Me.CreateGraphics
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim pen1 As Pen
pen1 = New Pen(Color.Gold, 5)
grap1.DrawLine(pen1, 5, 5, 150, 150)
End Sub
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
grap1 = Me.CreateGraphics
Dim pen1 As Pen
pen1 = New Pen(Color.Gold, 5)
grap1.DrawLine(pen1, 450, 450, 150, 150)
End Sub
--
"◢██◣ 呼呼呼~ 為什麼…我這麼愛你…
↙操B跑車 " ,█◥◥◥ ˊ 對不起,他有車。 ˋ ◢██◣
▄◣ ◤ ◎ ◎ ◣◢██◣ˊ █◥◥◥▌
◣◥◣ ◥ ▼◤ ▉█◥◥◥ ◤ ▇ ▇◤
██████ ◣ ╲██◣ ▉◤ ▄ ▄ ◥ █▲◤
██◤▄◥█▃ ◢ █▃●╲ ◤╲█"█◤ g121630作 ◢ ◣ ◣
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 116.118.151.23