p_dog_2007 Posted January 28, 2004 Posted January 28, 2004 Im trying to draw 30 by 30 tiles (bitmaps), into a panel, because when i get a lot of them I want to be able to scroll around instead of them taking up tha whole screen. I have the panel made and i can draw the tile but it draws the tile behind the panel so u cant see it, and its not in the panel. heres what draws the tile, my panels called mappanel Dim curcollum, currow as integer Dim curtile As New Bitmap("tiles/path.bmp") e.Graphics.DrawImage(curtile, MapPanel.Left + (currow * 30), MapPanel.Top - (curcollum * 30)) it runs just fine but it draws it behind the panel(I want it to draw it indi) can any one help? thanks Quote
Leaders dynamic_sysop Posted January 28, 2004 Leaders Posted January 28, 2004 take a look at the ClipRectangle property in the paint event. eg: Private Sub MapPanel_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MapPanel.Paint Dim curtile As New Bitmap("C:\dcp_0703.jpg") e.Graphics.DrawImage(curtile, e.ClipRectangle.X, e.ClipRectangle.Y) '/// where e.ClipRectangle.X is the very left of your panel , e.ClipRectangle.Y is top. End Sub Quote
p_dog_2007 Posted January 28, 2004 Author Posted January 28, 2004 re: what is the cliprectangle, what specifies that is part of the panel? thanks for your help, but I dont understand Quote
NK2000 Posted January 28, 2004 Posted January 28, 2004 cliprectangle is the part of the panel you see..everything outside of it wont be painted.. Quote
p_dog_2007 Posted January 28, 2004 Author Posted January 28, 2004 re: this is exactily what I wrote, and it didnt work, it drew it bedhind the panel not in the panel. How does cliprectangle know which panel to do it on, if i had more than one panel(i dont tho) e.Graphics.DrawImage(curtile, e.ClipRectangle.X + (currow * 30), e.ClipRectangle.Y - (curcollum * 30)) thanks Quote
NK2000 Posted January 28, 2004 Posted January 28, 2004 MapPanel_Paint there you see it is the Paint override of the MapPanel you can override every other class too but here it is the MapPanel, so e.ClipRectangle belongs to MapPanel :) hm why dont use picturebox if you just want to draw.. Quote
*Experts* mutant Posted January 28, 2004 *Experts* Posted January 28, 2004 Are you doing the drawing in the Panel's Paint event or the Form's Paint event? If you do it in Form's Paint, the panel will be drawn over what you drew. Quote
p_dog_2007 Posted January 28, 2004 Author Posted January 28, 2004 re: thanks, i didnt know you could do the paint event in the panel, it working now Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.