Solved

Moving Buttons on panel, not overlay

Posted on 2007-03-30
5
260 Views
Last Modified: 2013-11-07
Hello

I want to move several buttons on a panel. Thats working correctly.
But while moving I want to check if on the new place, there is alreasy a button.
I am using Mousemove, so it should check at every mousemove event, if the button I want to move will be on the top of another button...

How can I do that?

Thanks

Sven
0
Comment
Question by:Ruttensoft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:dctuck
ID: 18822455
If you are moving Button1, and want to check if it is over Button2, you could use:

If Button1.ClientRectangle.IntersectsWith(Button2.ClientRectangle) Then
....
End If

This checks the whole of the Button1 rectangle to see if any point in it overlaps Button2's area
0
 

Author Comment

by:Ruttensoft
ID: 18822459
Thanks.
I will have 40 controls, 20 buttons and 20 picturebox. Is it possible to check for all other 39 controls very fast?
0
 
LVL 7

Expert Comment

by:dctuck
ID: 18822461
Sorry - change ClientRectangle to Bounds, so:

If Button1.Bounds.IntersectsWith(Button2.Bounds) Then
....
End If

My mistake...
0
 
LVL 7

Accepted Solution

by:
dctuck earned 500 total points
ID: 18822472
This should work:

        For Each myControl As Control In Me.Controls
            If TypeOf (myControl) Is Button Then
                If Button1.Bounds.IntersectsWith(myControl.Bounds) Then
                    ......
                End If
            End If
        Next
0
 

Author Comment

by:Ruttensoft
ID: 18822476
thanks a lot
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question