473,498 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to find what control is in some position?

Hi:
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 3612
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.
PointedEars
Apr 1 '06 #2
VK

jkarpago wrote:
Hi:
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.elementFromPoint(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

2
2228
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...
10
1899
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...
4
2601
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,...
1
27001
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...
5
1730
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...
7
28334
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...
6
1998
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...
1
4747
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...
0
7125
marktang
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,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
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,...
0
5462
agi2029
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,...
1
4910
isladogs
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...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
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...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
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 ...

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.