?
Solved

Moving Buttons on panel, not overlay

Posted on 2007-03-30
5
Medium Priority
?
262 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 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

770 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