Question SplitContainers

dotnetnube

Member
Joined
Aug 20, 2008
Messages
8
Programming Experience
Beginner
Hi,

I'm trying to draw a rectangle in 'panel2' of a split container, but can't figure out how to do this. I tried using the Paint event, but didn't get the expected result using the following code (nothing happened):

VB.NET:
Private Sub SplitContainer1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles SplitContainer1.Paint
    Dim g As Graphics
    g = SplitContainer1.Panel2.CreateGraphics
    Dim rect As Rectangle = New Rectangle(230, 230, 100, 100)

    g.DrawRectangle(Pens.Black, rect)
End Sub

Thanks!
 
Last edited by a moderator:
Doubleclick the Panel you want to draw on to get the Paint event handler for that panel. Use the provided e.Graphics instance to draw there.
 
Back
Top