Advertisement

04.30.2008 at 12:43AM PDT, ID: 23364616
[x]
Attachment Details

rectangle on a usercontrol

Asked by dgb in .NET

Tags: MS, VB, .net

Hi,
I want to draw some rectangle's on a user control.
I use this code:
 Private Sub DrawRectangle()
      Dim myRectangle As Rectangle
       '  myGraphics = Graphics.FromHwnd(hwnd:=.ActiveForm().Handle)
      myGraphics = Graphics.FromHwnd(hwnd:=.ActiveControl().Handle)
      Dim nX As Integer
      Dim nY As Integer
      For nY = 1  To 300 Step 30
         For nX = 1 To 150 Step 10
            myRectangle = New Rectangle(nX, nY, Width:=30, Height:=10)
            myGraphics.DrawRectangle(pen:=New Pen(Color.Black), rect:=myRectangle)
         Next
      Next
   End Sub
When i put it on a form there is no problem, when I put it on a usercontrol it's not working.
myGraphics = Graphics.FromHwnd(hwnd:=.ActiveControl().Handle) give the problem. Any idea.
thnxStart Free Trial
[+][-]04.30.2008 at 02:45AM PDT, ID: 21469197

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: .NET
Tags: MS, VB, .net
Sign Up Now!
Solution Provided By: rachitkohli
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628