Reputation: 3435
I guess my question is very simple but I did not find any answer.
I have a vb.Net project with a MainForm and a Button(btn1
) and a UserControl(uc1
).
All I want is when I click on btn1 a simple line draw on uc1
using graphics
class.
thanks.
Upvotes: 2
Views: 2416
Reputation: 27322
Create a method in your UserControl to draw the line:
Public Class MyUserControl
Public Sub DrawLine()
Using g As Graphics = Me.CreateGraphics
g.DrawLine(Pens.Blue, New Point(10, 10), New Point(100, 50))
End Using
End Sub
End Class
Then call this from your button click:
Private Sub Button26_Click(sender As Object, e As EventArgs) Handles Button26.Click
MyUserControl1.DrawLine()
End Sub
This is a simple solution, but you may want to do all your drawing in the paint event of the usercontrol
Upvotes: 3