code to find all dynamic control locations on a form???

  • Thread starter Thread starter Marc
  • Start date Start date
M

Marc

Hi guys,

I have a selection of dynamically created controls on a form. I want to
be able to check the location of any of these controls and comare them
with the location of another control.
(This is actually to replicate the windows desktop drag-drop
functionality).

As an example I need something like:

If me.Controls.(??any control location????) = theButton.Location

Any ideas how i can do this....
 
Marc said:
Hi guys,

I have a selection of dynamically created controls on a form. I want to
be able to check the location of any of these controls and comare them
with the location of another control.
(This is actually to replicate the windows desktop drag-drop
functionality).

As an example I need something like:

If me.Controls.(??any control location????) = theButton.Location

Any ideas how i can do this....

Not quite sure what you're asking here...
You have some controls and you want to compare the location of any of
these controls to the locations of all the other controls?

The Location property of the control has an X and Y property which
should help...
exactly how do you want to compare the controls?
 
Its ok..i worked it out

For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is Button And ctrl IsNot theButton And
ctrl.Location = theButton.Location Then
MsgBox("jijj")
End If
Next
End If
 
Something like this:

If Button1.Bounds.IntersectsWith(Button2.Bounds) Then
Debug.WriteLine("Yep")
End If
 
Thanks I did not know this one.

Cor

Mudhead said:
Something like this:

If Button1.Bounds.IntersectsWith(Button2.Bounds) Then
Debug.WriteLine("Yep")
End If
 
Back
Top