473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to determen the object ?

Hi,

I've created a form and on the fly several pictureboxes are created...

Dim x As Integer = 0
Dim myCollection As List(Of PictureBox) = New List(Of PictureBox)
Dim Location As Integer = 50

For x = 0 To 5
Dim myBox As PictureBox = New PictureBox
myBox.SetBounds(50, Location * x, 34, 34)
myBox.BackColor = Color.Black
myBox.BringToFront()
myBox.AllowDrop = True
Me.Controls.Add(myBox)
myCollection.Add(myBox)
myBox = Nothing
Next

I would like to use drag and drop to put pictures in the pictureboxes and a
function like this ...

Private Sub picureBox_DragDrop(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles PictureBox3.DragDrop

End Sub

But what if I created the pictureboxes on the fly ? I can't use "handles
PictureBox" ...

I propably have the use the sender but how ?

John
Oct 6 '06 #1
2 1243
Lookup "AddHandler"

Thanks,

Seth Rowe

John Devlon wrote:
Hi,

I've created a form and on the fly several pictureboxes are created...

Dim x As Integer = 0
Dim myCollection As List(Of PictureBox) = New List(Of PictureBox)
Dim Location As Integer = 50

For x = 0 To 5
Dim myBox As PictureBox = New PictureBox
myBox.SetBounds(50, Location * x, 34, 34)
myBox.BackColor = Color.Black
myBox.BringToFront()
myBox.AllowDrop = True
Me.Controls.Add(myBox)
myCollection.Add(myBox)
myBox = Nothing
Next

I would like to use drag and drop to put pictures in the pictureboxes and a
function like this ...

Private Sub picureBox_DragDrop(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles PictureBox3.DragDrop

End Sub

But what if I created the pictureboxes on the fly ? I can't use "handles
PictureBox" ...

I propably have the use the sender but how ?

John
Oct 6 '06 #2
Exactly! You can do what Seth said and use the AddHandler method each time
you add a picturebox on the fly and point it to, maybe, the same
pictureBox_DragDrop method. Inside your method, you can do a Select Case or
something to detect which Picturebox called the method maybe something like
this:

Dim pic as PictureBox = sender ' you could also convert it yourself
using the Convert method or a DirectCast call.

Select Case pic.Name
Case "PictureBox1"
Case "PictureBox2"
End Select

Get the pattern here?

HTH
Steve
"John Devlon" <jo********@hotmail.comwrote in message
news:UD**********************@phobos.telenet-ops.be...
Hi,

I've created a form and on the fly several pictureboxes are created...

Dim x As Integer = 0
Dim myCollection As List(Of PictureBox) = New List(Of PictureBox)
Dim Location As Integer = 50

For x = 0 To 5
Dim myBox As PictureBox = New PictureBox
myBox.SetBounds(50, Location * x, 34, 34)
myBox.BackColor = Color.Black
myBox.BringToFront()
myBox.AllowDrop = True
Me.Controls.Add(myBox)
myCollection.Add(myBox)
myBox = Nothing
Next

I would like to use drag and drop to put pictures in the pictureboxes and
a function like this ...

Private Sub picureBox_DragDrop(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles PictureBox3.DragDrop

End Sub

But what if I created the pictureboxes on the fly ? I can't use "handles
PictureBox" ...

I propably have the use the sender but how ?

John

Oct 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: lawrence | last post by:
How dangerous or stupid is it for an object to have a reference to the object which contains it? If I have a class called $controllerForAll which has an arrray of all the objects that exist, what...
15
by: Ville Vainio | last post by:
Pythonic Nirvana - towards a true Object Oriented Environment ============================================================= IPython (by Francois Pinard) recently (next release - changes are...
1
by: Bijay Kumar | last post by:
Hi Guys, I was going through the source code of Object.cs in rotor. What I found is Equals() implemented as follows: public extern virtual bool Equals(Object obj); What I don't...
28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
7
by: Nick Zdunic | last post by:
I have a remotable object running in my host application. The host starts up and creates the object. Within a method to start the remote object doing its thing it creates an object. ...
0
by: Bijay Kumar | last post by:
Hi Guys, I was going through the source code of Object class (Object.cs in rotor). What I found is Equals() implemented as follows: public extern virtual bool Equals(Object obj); What...
26
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized...
3
by: User1014 | last post by:
A global variable is really just a property of the "Global Object", so what does that make a function defined in the global context? A method of the Global Object? ...
2
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.