Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Leaders
Posted

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

Posted

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

Posted

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..

  • *Experts*
Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...