Solved

Moving Buttons on panel, not overlay

Posted on 2007-03-30
5
256 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
  • 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Support for Notepad++ (including downloading & installing a plugin) 5 121
Expression Evaluater 3 26
C# LINQ ForEach() question 6 28
VB.NET 2008 Winforms Signing 13 19
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

810 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