Scroll to owner drawn Rectangle - plz help
-
I am facing problem with my custom control. Please help urgently. My control inherits a Windows.Forms.Panel control. I have set the AutoScroll property of the base control (panel) to true. I added a PictureBox in the at location (Left = 0, Top = 0) in the panel control. Size of the PictureBox is large enough to show the ScrollBars for the base control (panel). In the Paint Event handler of the picture Box I am drawing a rectangle. To scroll (make it visible completely in the Client area) to the drawn rectangle, I added a transparent Label control and set its bounds(location, size) as of drawn rectangle in runtime after drawing the rectangle and called the Panel's ScrollControlIntoView method. Scrolling works, but when I change the location and size of the rectangle to draw it to another location, the rectangle intersects the client rectangle of my control (i.e. not visible completely in the client rectangle). How can I avoid it? How do I know if my rectangle is intersecting the client rectangle? Or How do I position my transparent label such that it is completely visible in the client rectangle? Or Suggest me any other way Thank You, Gulfraz Khan