Delete images problem
Delete images problem
Delete images problem
Delete images problem
Delete images problem
Delete images problem Delete images problem Delete images problem Delete images problem Delete images problem Delete images problem Delete images problem Delete images problem
Delete images problem Delete images problem
Delete images problem
Go Back  Xtreme Visual Basic Talk > > > Delete images problem


Reply
 
Thread Tools Display Modes
  #1  
Old 11-12-2012, 09:50 PM
Elpat Elpat is offline
Newcomer
 
Join Date: Nov 2012
Posts: 1
Default Delete images problem


Hi!

I am building my own version of Tron on vb for fun, and I have a small problem...
To create a line behind the blue and red dots, I used this code :

Dim lignetronrouge As New PictureBox

tabrouge(lrouge) = New System.Drawing.Point(tronrouge.Location.X, tronrouge.Location.Y)

lignetronrouge.Image = My.Resources.motorouge102

lignetronrouge.Location = New System.Drawing.Point(tronrouge.Location.X, tronrouge.Location.Y)

lignetronrouge.Size = New System.Drawing.Size(10, 10)

lignetronrouge.Visible = True

Me.Controls.Add(lignetronrouge)

---------------------------------------------------------------------------

It works very well, but when the dots touch a side of the screen,themselves or each other, I want the lines to disappear. What should I do to delete all the created pictureboxs? I can't use "lignetronrouge" outside of this sub, but if I make it public, the lines don't stay behind the dots. Thanks for answering me and sorry for my bad english it is not my first language.

Pat
Reply With Quote
  #2  
Old 11-13-2012, 06:03 AM
passel's Avatar
passelDelete images problem passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

Hopefully you will soon learn to use drawing commands to draw your games rather than using a lot of controls, which is very wasteful, but in the meantime the simplest approach, I think, would be to create a list of the rouge or bleu pictureboxes as you create them, then use that list to remove them from the Me.Controls list.
Quick example, requires a button on a form.
Wherever you click the mouse on the form a small (10x10 pixel) red picturebox will be created.
When you click the button, all the pictureboxes will be deleted.
Code:
Public Class Form1

  Dim listRouge As New List(Of PictureBox)

  Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
    Dim lignetronrouge As New PictureBox

    lignetronrouge.BackColor = Color.Red
    lignetronrouge.Location = e.Location
    lignetronrouge.Size = New System.Drawing.Size(10, 10)
    lignetronrouge.Visible = True

    Me.Controls.Add(lignetronrouge)
    listRouge.Add(lignetronrouge)
  End Sub

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    For Each c As PictureBox In listRouge
      Me.Controls.Remove(c)
    Next
    listRouge.Clear() 'we removed all our pictureboxes, so clear the list
  End Sub
End Class
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Delete images problem
Delete images problem
Delete images problem Delete images problem
Delete images problem
Delete images problem
Delete images problem Delete images problem Delete images problem Delete images problem Delete images problem Delete images problem Delete images problem
Delete images problem
Delete images problem
 
Delete images problem
Delete images problem
 
-->