473,555 Members | 2,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to find what control is in some position?

I need to find what control is in some position given.
I mean, if I give the values left: 200px and top 300px I need to know
what control in the page is in that position, or if there is not any.
Can anyone help me, please?

Thanks so much.

Apr 1 '06 #1
3 3614
jkarpago wrote:
I need to find what control is in some position given.
I mean, if I give the values left: 200px and top 300px I need to know
what control in the page is in that position, or if there is not any.

You will need a bubbling event, then evaluate its event target in its event
listener. If that target is the element on which you are listening for
the event, none of its descendants handled it. Otherwise, the computed
coordinates of the handling descendant indicate its location. This
approach is efficient (AIUI, O(1)) but unprecise insofar that more than
one element can be at that position, and only the topmost element this
event applies to will be identified as event target.

Another more precise approach is to compute the area each element covers,
and then run a comparison for each element, in O(n).

Bottom line:
Describe what you are up to, not what you /think/ you need to know to do it.
Apr 1 '06 #2

jkarpago wrote:
I need to find what control is in some position given.
I mean, if I give the values left: 200px and top 300px I need to know
what control in the page is in that position, or if there is not any.
Can anyone help me, please?

Thanks so much.

For IE use document.elemen tFromPoint(x,y) method.

For the Co you need to dig it out manually as suggested.

Apr 1 '06 #3
Thanks for your help. That´s what I imagine, but I wanted to know if
there was another solution.
Thanks so much

Apr 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: David K. | last post by:
My question concerns C# Windows Forms user controls. I have created navigation user control. It gets the parent control's CurrencyManager to its bindable property. In the control, any change in the CurrencyManager position is displayed OK. But the problem is that the position of the parent CurrencyManager stays intact (doesn't change at all)....
by: dale zhang | last post by:
Hi, I saw the post here about setfocus. But they are for web form. Web control page HTML does not have form1. the Jscript there does not work here. My question is how to set focus to the text box in web control page?
by: Aaron Smith | last post by:
Dim dv As DataView = New DataView(FacilitiesDS1.Facilities, "", "ID ASC", DataViewRowState.CurrentRows) Dim iPos As Integer = dv.Find(dr.Item("ID")) Me.BindingContext(FacilitiesDS1, "Facilities").Position = iPos That is the code.. dr is DataRow. If dr.Item("ID") = 3, the find will return position 0, which it should have been 1, and if the...
by: Simon Verona | last post by:
I have a usercontrol which when entered pops up a form. I want the form to be aligned with the bottom edge of the user control. I was doing this by passing the usercontrol into the form as a parameter and using the left and top properties to find the location on the screen to position the form. However, these are relative to the container...
by: sagar | last post by:
is there any way to find the position of mouse click on a form actually the problem is i m having more than one controls on a form i want to find which control is selected using mouse down any help is fine for me thanks
by: Joe-Paul Robb, Jr. | last post by:
Hello: I am building a program in Visual Basic 6.0. (Op Sys: Windows XP 2002 Service Pack 2) I placed an AOD Data Control on a form...and a data Grid. I bound the data grid to the data control. Then used the following code to populate the data control ...and thus, the grid: With datPos
by: Samuel Rhodes | last post by:
Hi I am trying to write a code snippet that would display a '?' sign on the top left of a control. I do not want to hard code the positioning of the DIV which will contain that '?'. Is it possible to somehow know the top, left position of the content rendered by a User Control in a asp page. For eg, assume the figure below as a web...
by: Randy | last post by:
I'm struggling with identifying whether a user has clicked on the left or right arrows within the MonthCalendar controls. I had a good suggestion to trap the mouse coordinates that the user clicks to determine if they have clicked within the region where the arrow exists. My problem is that my form is not maximized and therefore the control...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.