is a control an item in a collection?

If I have a control on a form, is there any way I can tell if it is an item in a collection and what the collections name is?

For example:
I want to be able to click on a button and have it return false if it is not an item in a collection, and if it is an item in a  collection, then have it return which collection it is in.

Thanks and Cheers!
ahammar
LVL 23
ahammarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
forms.controls  collection holds all the controls on the form
if you have your own collections, you cannot tell from the control itself if it is in any collection, you have to "ask" the collection objects to check which it is in.
jimbobmcgeeCommented:
Why do you need this feature?  Perhaps there is an alternative we can come up with...?
ahammarAuthor Commented:
Hi you two...

Thanks for you comments.

This is kinda long, so don't read it if you're not interested.  This just explains why I wanted to do this.

I actually did come up with a workaround, but the reason I wanted this was because my app has 6 different controls that each display a different symbol (lines, circles, rectangles etc...) that can be dimensioned as I need them to be.  At run time I load them as I need them, shape and size them, and move them around with my mouse to form a picture.

I can select a group of them using a method called rubberbanding (thanks to Idle Mind) and move the group around.  What I wanted was to make a selection of controls, then have the option to actually make them into a permanant group so that they would always be moved together as a group as if they were 1 without having to select the entire group again each time I wanted to move them, in other words, once a selection of controls was made into a group, from that point on, they would all move together, even by moving just 1. (When I say permanant, I mean unless I ungroup them)
The only way I could think of to do this when I asked this question (without a lot of changing things) was to select the controls I wanted to turn into a group, then have each control in the selection be added to a collection, (each collection being named with a number 1 higher than the previous in case of more than 1 group was created).  Then when I clicked on 1 control that was in the collection and moved it with my mouse, it would also move the rest of the ones in the same collection with it to keep the grouped controls together.  Which meant that when I clicked on a control that was part of a collection (group) to move the group around,  I had to know the name of the collection that it was a part of, so that the code that moved the control, would know which collection of controls to move with it.  I was afraid I'd get the answer that AngelIII gave, but I had to ask.
The first idea I had before this one (which in a sense is what I ended up doing), was instead of adding each control in a selection to a collection, just setting each of their tags to an equal number.  That way they would be grouped by the number of their tag.  There was 2 reasons why I didn't want to do this.  It is slower because now my code has to check every control on the form for their tag number to see which ones to move together instead of just moving the ones in a collection, and reason 2...I was already using the tag property for something else.
So I had to add a property to each of the 6 controls (they are custom controls) to act like a second tag, and that's the way I ended up doing it.

Sorry that was so long, but it's just in case you were interested, and I am still open for suggestions if you know a way that would be faster.  The tag idea works good, but there might be a faster way.

Thanks and Cheers!
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Mark_FreeSoftwareCommented:

just a quick idea:

what about putting them in a picturebox of frame?
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
For those interested in the History of the question:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21642437.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21659699.html

Click and drag the Labels to move them around the Form.

You can select multiple Labels by rubberbanding them or by holding down the control key and clicking on the Labels to toggle their selection status.

You can Copy/Paste Labels when they are selected individually, or as selected as part of a multiple selection, or as a group.

You cannot make a Label part of more than one group.  Also, you cannot group together multiple groups.  To do this would require more indepth code and logic.

To add another Label to an existing group:
    First, click on the "Ungroup" button.
    Then, add the Label to the current selection by holding down the control key and clicking the additional Label.
    Finally, click on the "Group" button to group all the selected Labels together again.

Create a New Project.
Click on Project --> References and check the "Microsoft Scripting Runtime" entry.
Add two CommandButtons to the form and change their names/captions to "cmdCopy" and "cmdPaste".
Add two CommandButtons to the form and change their names/captions to "cmdGroup" and "cmdUngroup".
Add a Label (Label1) and then cut and paste that label several times to make a control array.

Option Explicit

Private Declare Function GetCursorPos Lib "user32" (lpPoint As Point) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex&) As Long
Private Declare Function SetROP2 Lib "gdi32" (ByVal hdc As Long, ByVal nDrawMode As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle&, ByVal nWidth&, ByVal crColor&) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
Private Declare Function Rectangle Lib "gdi32" (ByVal hdc&, ByVal X1&, ByVal Y1&, ByVal X2&, ByVal Y2&) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As Rect) As Long
Private Declare Function IntersectRect Lib "user32" (lpDestRect As Rect, lpSrc1Rect As Rect, lpSrc2Rect As Rect) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As Point) As Long
Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

Private Type Point
    X As Long
    Y As Long
End Type

Private Type Rect
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

' related to drawing/draggging the rubberbanding box
Private Const SW_NORMAL = 1
Private Const NULLBRUSH = 5
Private Const VK_CONTROL = &H11
Private desktopDC As Long
Private cxBorder As Long
Private capturing As Boolean
Private startBox As Point
Private lastPt As Point
Private endBox As Point

' related to tracking/dragging the selected controls
Private isGrouped As New Dictionary
Private groups As New Collection
Private curGroup As String

Private selected As New Collection
Private selectedCopy As New Collection
Private sX As Single
Private sY As Single
Private dragged As Boolean

Private Sub Form_Load()
    capturing = False
    cxBorder = GetSystemMetrics(5) ' window border size (determines width of the rubberband outline)
   
    ' make all the labels flat and have the same background as the form
    ' we will make the labels appear "selected" by setting the
    ' borderstyle to 1
    Dim c As Control
    For Each c In Me.Controls
        If TypeOf c Is Label Then
            c.Appearance = 0 'flat
            c.BackColor = &H8000000F
        End If
    Next
   
    ' set the initial state of the grouping buttons
    cmdGroup.Enabled = False
    cmdUngroup.Enabled = False
End Sub

Private Sub cmdCopy_Click()
    ' make a new collection that will hold a reference to all the currently selected labels
    Set selectedCopy = New Collection
    Dim c As Control
    For Each c In selected
        selectedCopy.Add c
    Next c
End Sub

Private Sub cmdPaste_Click()
    ' unselect the currently selected controls
    ' for each label in the selectedCopy collection...
    ' add a new label to the form and copy that labels dimensions
    ' add each new label the selected collection
    ' select all the new controls in the selected collection
    Dim c As Control
    Dim index As Integer
    If selectedCopy.Count > 0 Then
        SelectControls selected, False
        Set selected = New Collection
        For Each c In selectedCopy
            index = Label1.UBound + 1
            Load Label1(index)
            Label1(index).Left = c.Left + Me.ScaleX(0.5, vbInches, Me.ScaleMode)
            Label1(index).Top = c.Top + Me.ScaleY(0.25, vbInches, Me.ScaleMode)
            Label1(index).Width = c.Width
            Label1(index).Height = c.Height
            Label1(index).Caption = c.Caption
            Label1(index).Visible = True
            selected.Add Label1(index)
        Next c
        SelectControls selected, True
       
        ' if we copied a group then create a new group from
        ' the pasted controls
        If curGroup <> "" Then
            cmdGroup_Click
        End If
    End If
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ' unselect any previously selected controls
    SelectControls selected, False
    Set selected = New Collection
    curGroup = ""
    SetGroupingButtons

    ' set the capturing flag and the starting position of the box,
    ' and clip the cursor to the form so we can't drag our rubberband
    ' outside the form itself
    capturing = True
    GetCursorPos startBox
    lastPt.X = startBox.X
    lastPt.Y = startBox.Y
    rubberBand lastPt
    Dim r As Rect
    Call GetWindowRect(Me.hwnd, r)
    Call ClipCursor(r)
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ' if the mouse has moved more than the rubberbanding border width,
    ' then erase the previous box, draw the new box and update the box location
    Dim pt As Point
    If capturing Then
        GetCursorPos pt
        If Abs(pt.X - startBox.X) >= cxBorder And Abs(pt.Y - startBox.Y) >= cxBorder And _
                (pt.X <> lastPt.X Or pt.Y <> lastPt.Y) Then
            rubberBand lastPt
            rubberBand pt
            lastPt.X = pt.X
            lastPt.Y = pt.Y
        End If
    End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ' clear the capturing flag, erase the final rubberbanding box
    ' reset the cursor clipping so the mouse can leave the form again
    capturing = False
    GetCursorPos endBox
    rubberBand endBox
    Call ClipCursor(Null)
   
    ' unselect any previously selected controls
    SelectControls selected, False
    ' see what was selected
    Set selected = FindSelectedControls()
    ' select the new controls
    SelectControls selected, True
    ' clear the curGroup variable
    curGroup = ""
    SetGroupingButtons
End Sub

Private Sub rubberBand(curPt As Point)
    Dim hPen&, hOldPen&, hOldBrush&, hNullBrush&
   
    Dim cr As Long
    Dim rc As Rect
    Const NULL_BRUSH = 5
    Const R2_NOT = 6
    Const PS_INSIDEFRAME = 6
       
    ' normalize the box
    If startBox.X < curPt.X Then
        rc.Left = startBox.X
        rc.Right = curPt.X
    Else
        rc.Left = curPt.X
        rc.Right = startBox.X
    End If
   
    If startBox.Y < curPt.Y Then
        rc.Top = startBox.Y
        rc.Bottom = curPt.Y
    Else
        rc.Top = curPt.Y
        rc.Bottom = startBox.Y
    End If

    ' get a device context to the desktop so we can draw on top of everything
    desktopDC = GetWindowDC(GetDesktopWindow())
   
    ' Create an inverse pen that is the size of a window border.
    SetROP2 desktopDC, R2_NOT
    cr = RGB(0, 0, 0)
    hPen = CreatePen(PS_INSIDEFRAME, 3 * cxBorder, cr)

    ' store the previous pen and select our pen created above
    hOldPen = SelectObject(desktopDC, hPen)
    hNullBrush = GetStockObject(NULL_BRUSH)
    ' store the previous brush and select our null brush
    hOldBrush = SelectObject(desktopDC, hNullBrush)
    ' draw the rectangle
    Rectangle desktopDC, rc.Left, rc.Top, rc.Right, rc.Bottom
    ' put the stored brush and pen back
    SelectObject desktopDC, hOldBrush
    SelectObject desktopDC, hOldPen
    ' delete our created pen and brush
    DeleteObject hPen
    DeleteObject hNullBrush
    ' release our device context
    ReleaseDC GetDesktopWindow(), desktopDC
End Sub

Private Function FindSelectedControls() As Collection
    Dim c As Control
    Dim p As Point
    Dim selectR As Rect
    Dim controlR As Rect
    Dim intersectR As Rect
       
    Set FindSelectedControls = New Collection
   
    ' normalize the selection box
    If startBox.X < endBox.X Then
        selectR.Left = startBox.X
        selectR.Right = endBox.X
    Else
        selectR.Left = endBox.X
        selectR.Right = startBox.X
    End If
    If startBox.Y < endBox.Y Then
        selectR.Top = startBox.Y
        selectR.Bottom = endBox.Y
    Else
        selectR.Top = endBox.Y
        selectR.Bottom = startBox.Y
    End If

    ' calculate intersections for each control
    Set selected = New Collection
    For Each c In Me.Controls
        ' for controls with an hWnd, use the line below
        'Call GetWindowRect(c.hwnd, controlR)
   
        ' for controls with no hWnd (like the label), use code like below
        If TypeOf c Is Label Then
            p.X = Me.ScaleX(c.Left, Me.ScaleMode, vbPixels)
            p.Y = Me.ScaleY(c.Top, Me.ScaleMode, vbPixels)
            Call ClientToScreen(Me.hwnd, p)
            controlR.Left = p.X
            controlR.Top = p.Y
            controlR.Right = controlR.Left + Me.ScaleX(c.Width, Me.ScaleMode, vbPixels)
            controlR.Bottom = controlR.Top + Me.ScaleY(c.Height, Me.ScaleMode, vbPixels)
           
            Call IntersectRect(intersectR, selectR, controlR)
            If ((intersectR.Right - intersectR.Left) > 0) Or ((intersectR.Bottom - intersectR.Top) > 0) Then
                ' only allow rubberbanding of non-grouped controls
                If Not isGrouped.Exists(c) Then
                    FindSelectedControls.Add c
                End If
            End If
        End If
    Next c
End Function

Private Sub SelectControls(ByVal col As Collection, ByVal state As Boolean)
    ' this code is specific to a Label but can be extended to handle
    ' anything really.  Just toggle the "state" of the object/control
    ' based on the passed in state variable
    Dim c As Control
    For Each c In col
        If state Then
            c.BorderStyle = 1
        Else
            c.BorderStyle = 0
        End If
        c.Refresh
    Next c
End Sub

Private Sub Label1_MouseDown(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbLeftButton Then
        ' set the starting position of a potential drag operation
        sX = X
        sY = Y
        dragged = False
       
        ' check to see if the control being clicked is part of a group
        ' and act accordingly
        ' no other controls may be selected while a group is selected
        Dim c As Control
        Set c = Me.Controls("Label1")(index)
       
        If isGrouped.Exists(c) Then
            ' get the group name of this control
            Dim groupName As String
            groupName = isGrouped.Item(c)
           
            If groupName <> curGroup Then
                ' unselect any currently selected controls
                SelectControls selected, False
           
                ' get the collection that contains all the controls
                ' in this group
                Dim group As Collection
                Set group = groups.Item(groupName)
           
                ' select all the controls in this group
                Set selected = New Collection
                For Each c In group
                    selected.Add c
                Next
                SelectControls selected, True
   
                ' set the current group name
                curGroup = groupName
               
                DoEvents
            End If
        Else
            ' unselect the current group if there is one
            If curGroup <> "" Then
                SelectControls selected, False
                Set selected = New Collection
                curGroup = ""
            End If
       
            ' if the control key was not down,
            ' and the control was not selected,
            ' then clear any previously selected
            ' controls and make this control the
            ' only selected control.
            ' otherwise, if the control key was down,
            ' then toggle the selection state of the control
            If Not CtrlKey Then
                If Label1(index).BorderStyle = 0 Then
                    SelectControls selected, False
                    Set selected = New Collection
                    selected.Add Label1(index)
                    SelectControls selected, True
                End If
            ElseIf Label1(index).BorderStyle = 0 Then
                selected.Add Label1(index)
                SelectControls selected, True
            Else
                Label1(index).BorderStyle = 0
                Dim i As Integer
                For i = 1 To selected.Count
                    If selected.Item(i) Is Label1(index) Then
                        selected.Remove i
                        Exit For
                    End If
                Next
            End If
        End If
        SetGroupingButtons
    End If
End Sub

Private Sub Label1_MouseMove(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    ' if the mouse is moved while the left button
    ' is depressed and the control key is NOT down,
    ' then move all selected controls with respect to
    ' the starting location set in the MouseDown event
    If Button = vbLeftButton And Not CtrlKey Then
        ' the dragged flag will tell us if the
        ' mouse was dragged before being released
        dragged = True
        Dim c As Control
        For Each c In selected
            c.Left = c.Left + (X - sX)
            c.Top = c.Top + (Y - sY)
        Next
    End If
End Sub

Private Function CtrlKey() As Boolean
    ' returns True if the control key is down, otherwise returns False
   CtrlKey = GetKeyState(VK_CONTROL) And &H80
End Function

Private Sub cmdGroup_Click()
    Static groupCounter As Long
       
    If selected.Count > 1 Then
        ' create a new group name
        Dim groupName As String
        groupCounter = groupCounter + 1
        groupName = "Group" & groupCounter
       
        ' add the currently selected controls to a new group
        ' and set the groupname for each of these controls
        Dim groupCol As New Collection
        Dim c As Control
        For Each c In selected
            isGrouped.Add c, groupName
            groupCol.Add c
        Next c
       
        ' add the new group to our groups collection
        groups.Add groupCol, groupName
        curGroup = groupName
        SetGroupingButtons
    End If
End Sub

Private Sub cmdUngroup_Click()
    If curGroup <> "" Then
        ' clear the groupname for each of the controls
        ' in the current group
        Dim group As Collection
        Set group = groups.Item(curGroup)
        Dim c As Control
        For Each c In group
            isGrouped.Remove c
        Next
       
        ' delete the current group
        groups.Remove curGroup
        curGroup = ""
        SetGroupingButtons
    End If
End Sub

Private Sub SetGroupingButtons()
    If curGroup <> "" Then
        cmdGroup.Enabled = False
        cmdUngroup.Enabled = True
    Else
        If selected.Count > 1 Then
            cmdGroup.Enabled = True
            cmdUngroup.Enabled = False
        Else
            cmdGroup.Enabled = False
            cmdUngroup.Enabled = False
        End If
    End If
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ahammarAuthor Commented:
Hello all...

Thank you all for your comments.
I think I will have to give the points to Idle Mind for this solution.  It works good.   It would of simplified things a lot just to be able to have a control know what collection it was an item of, but I've concluded that's not possible.  At a glance, it appears that Idle Mind's code uses a collection of collections to form the groups...with each item in a main collection being a collection of controls.  This will require a large amount of change in my app (and I've already got at least 300 hours into it), so I'm not going to get to it right away, but I am eventually going to change it over.  So I am glad to have this solution.  As I said, it works good.
It's great to have had each one of you want to help me find a solution.
I considered Mark Freeware's comment, but I couldn't figure out how to duplicate the controls that I wanted to group together into the picturebox, and have them be the same size and shape and positioned the same as they were on the form when I turned them into a group (put them in the picturebox).

I won't accept any answers here yet just in case someone else wants to show me how to do that.  Then maybe I could split points or something, otherwise, I will accept Idle Mind's solution as answer in a while.  I think he has deserved it here so far.
No matter how simple of a solution I get, it's going to take a lot of change in my app, so I still want to use whatever solution I can get that will require the least amount of change.

Thank you all!
Cheers!
ahammar
ahammarAuthor Commented:
Sorry for my contradiction in my last comment.  I said I was going to accept Idle Mind's solution then in the end said I was going to wait a little while.  I had a change of mind at the last minute and forgot what I had previously wrote.  I guess I gotta quit writing so much....lol

ahammar
Mark_FreeSoftwareCommented:

i haven't got the time to work it out so it is compatible with your current code, but here is the idea (everyone that has time is welcome to work it out ofcourse):


get the position of the upper left control

place that at 0,0 in the picturebox
the other controls in the picturebox at their original location, minus the location of the upper left control

only problem with this is, that if there are controls between not selected, they will fall behind the picurebox, and with multiple pictureboxes it can get a little complicated which one is the topmost, so i think idle_mind's solution is (as almost always :P ) the best


happy coding,
mark
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
My approach is twofold:

    (1) I use a Dictionary as a lookup table to tell me if a Control is part of a group.  The control is the key itself and the group name is the value.  I can see in one line if a control is part of a group:

            If isGrouped.Exists(c) Then
 
    The Exists() method tells us if the "key" (in this case the control) is present in the dictionary.  If it is, then we retrieve the controls group name:

            groupName = isGrouped.Item(c)

    (2) I then use a Collection of Collections to hold the groups using the group name as the key.  Each group is a collection that holds references to all controls in the group:

            Set group = groups.Item(groupName)

I think this is the easiest and most flexible solution.   Unfortunately, this type of behaviour isn't trivial.  By keeping the groups as collections you could add functionality that affects all controls in the group by passing the group collection to subs/functions and simply enumerating the collection inside.

I'm sure there are many other ways to do this and I would love to see how someone else would accomplish it.  =)
jimbobmcgeeCommented:
Just a small snippet to back up Mark_FreeSoftware's approach; the following groups all Labels on a form into Picture1, at the click of Command1.  It's just an idea I had to show how it _could_ be done and, although I haven't tried it, I'd put money on Idle_Mind's answer being better (even with all those API references!!):

    Private Sub Command1_Click()
        Dim oCtrl As VB.Control
       
        Dim nLeft As Single, nRight As Single, _
            nTop As Single, nBottom As Single
           
        'INIT TO OPPOSITE MAX VALUES
        nLeft = Me.ScaleWidth
        nRight = Me.ScaleLeft
        nTop = Me.ScaleHeight
        nBottom = Me.ScaleTop
       
        'LOOP THROUGH CONTROLS
        For Each oCtrl In Me.Controls
            If oCtrl.Container Is Me Then   'IF NOT ALREADY GROUPED
                If TypeOf oCtrl Is VB.Label Then
                    If oCtrl.Left < nLeft Then nLeft = oCtrl.Left
                    If oCtrl.Top < nTop Then nTop = oCtrl.Top
                    If (oCtrl.Left + oCtrl.Width) > nRight Then nRight = (oCtrl.Left + oCtrl.Width)
                    If (oCtrl.Top + oCtrl.Height) > nBottom Then nBottom = (oCtrl.Left + oCtrl.Width)
                    Set oCtrl.Container = Picture1
                End If
            End If
        Next oCtrl
       
        'REPOSITION CONTROLS
        For Each oCtrl In Me.Controls
            If oCtrl.Container Is Picture1 Then
                oCtrl.Left = oCtrl.Left - nLeft
                oCtrl.Top = oCtrl.Top - nTop
            End If
        Next oCtrl
        Picture1.Move nLeft, nTop, (nRight - nLeft), (nBottom - nTop)
    End Sub

If you were to take this approach, you could determine whether a clicked item is within a group with the following logic (pseudo):

    Set oSelectControl = oClickedControl
    Do Until oSelectControl.Container Is Me
        Set oSelectControl = oSelectControl.Container
    Loop
    SelectControl(oSelectControl)

HTH

J.
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
You guys haven't tried my code out?...It's easy enough to build and play with.

The "grouping portion" of the code is relatively small.  Most of the code there is for rubberbanding, moving controls, and copy/paste functionality...

@jim: 99% of the APIs are being used for the Rubberbanding portion.
ahammarAuthor Commented:
Thanks again to all of you.

Ok, I tried out the picturebox code and it works too.  The only problem is, as someone mentioned before, is that everything behind the picture box is covered and I don't think I can make the picturebox backstyle transparent.  So that won't work in my situation.  As I move the picturebox around, I would have to be able to see through it so I could see everything behind it.  But it was a good thing to learn.
Also as Idle Mind mentioned, most of the code he offered is for rubberbanding and copy/paste which I am already using.

What I would like to do is give Mark Free Software and jimbobmcgee each 50 points, and Idle Mind the other 150 for an answer that works best in my situation.

Is that good for everyone?

Thanks and Cheers!
ahammar
Mark_FreeSoftwareCommented:

that should be kind of you, but i think Idle_Mind is deserving the points


good luck, and happy coding!

mark

ps Idle_Mind, will ya please take a look at this one: http://Q_21739306.html
thanx
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
Please give all those who participated some points...I have plenty already!   ;)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.