473,378 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Telling if a Button overlaps

I am making it that when they click the form it adds a button. Sometimes however if they click to close to another button then it makes them overlap. Is there any easy way to tell if the buttons over lap or not? I was thinking of making a function that will run and return true or false if they overlap or not. The buttons are all Size 30,30.

My initial thinking was take the location of the current button, then subtract the location of the new button. If it is between -30 and +30 then that means they overlap. But I can't get it to work for the life of me.

If anyone has any ideas please let me know.

This is the code I TRIED to use

private bool OverLapped(Button clickedButton)
{
foreach (Button ifButton in this.Controls)
{
if (ifButton.Name != clickedButton.Name)
{
if (clickedButton.Location.X - ifButton.Location.X < 30&& clickedButton.Location.X - ifButton.Location.X > -30 &&clickedButton.Location.Y - ifButton.Location.Y < 30&& clickedButton.Location.Y - ifButton.Location.Y > -30 )
return false;
}
}
return true;
}





Thanks alot.

Rob
Apr 4 '07 #1
2 930
SammyB
807 Expert 512MB
Just use the ControlsOverlap function in https://bytes.com/showthread.php?t=351400
Apr 4 '07 #2
Wow SammyB, thanks SO much. I did a basic search and didn't come with any thing. Not sure how I missed it. That worked WONDERFULLY!

SammyB For El Presidente!
Apr 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: axion_sa | last post by:
Hi, What I have is a booking table, and when updating/inserting I need to ensure that there are no date/time overlaps. The problem I'm having is that while the following script works for...
0
by: Red | last post by:
See http://reenie.org/test9.php There are two examples each with three nested divs. The only difference between the two is that the first example has no padding in the inner div, the second...
1
by: Mark Carroll | last post by:
With this page, <HTML> <HEAD><TITLE>Test page</TITLE></HEAD> <BODY STYLE="color: black; background: white"> <TABLE STYLE="float: left; clear: both"><TR> <TD STYLE="background: blue; width:...
20
by: Andrew Poulos | last post by:
If I have a page with a bunch of content and some javascript in the head how do I notify the javascript disabled users that enabling javascript would enhance their experience. At the moment I'm...
1
by: singmadhan | last post by:
Hi Frnds, I am working in an ASP.Net Application and creating a DHTML menu using JavaScript. There is a drop down list box below the menu, when ever I am dragging the menu the DropDownList box...
1
by: antonyliu2002 | last post by:
I am using the server side Toggle Controls implemented by Jos (cf: http://www.codeproject.com/aspnet/ToggleControls.asp), which is pretty cool, if you wanna toggle controls. On my web page, I...
2
by: rhyme2ri2 | last post by:
Hi!! I'm using asp.net 1.1 I have a datalist which gets dynamic data which is of unbound size may be small sometimes and may be very very long sometimes....... Whatever the size of data may be...
1
by: prpradip | last post by:
In my application ListView is inside panel (XP theme enable), item text in the ListView control overlaps other items in small icon view. The items are drawn as if aligned to a grid and this causes...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.