Results 1 to 3 of 3

Thread: Creating events for runtime objects

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    1

    Angry

    I wonder if anyone can help....

    I need to be able to click on a picture box created at run. The picture boxes are created using the code:

    Set objFurn = frmRoom.Controls.Add("vb.PictureBox", "Furnbox" & index)

    how dow i access these picture boxes by clicking on them at run-time?

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    For single controls you can use withevents as follows:
    Code:
    Private WithEvents objFurn As PictureBox
    To use control arrays i think you have to create an invisible dummy control and use Load to load up other instances of it.
    To use an array of controls, make a wrapper class for the picturebox and use withevents as above. Then Create your own events using Event statement that will raise the events you get from the picturebox into the classcollection of the wrapper classes, then raise overall events from the wrapper class that could contain the index part you usually see in control array events.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Guest
    Code:
    Private WithEvents pic As PictureBox
    
    Private Sub Form_Load()
        Set pic = Me.Controls.Add("VB.PictureBox", "Picture1")
    End Sub
    
    Private Sub pic_Click()
        MsgBox "You clicked the PictureBox"
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width