Re: Get name of control at a certain mousedown point

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Bob Powell [MVP] (bob_at__spamkiller_bobpowell.net)
Date: 02/11/05


Date: Fri, 11 Feb 2005 15:00:41 +0100

The mouse event's will be handled by the individual controls so you'll need
to wire all the controls click events up to a handler in the tab page or tab
control.

-- 
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Brad" <ballison@ukcdogs.com> wrote in message 
news:%237iqPEEEFHA.3120@TK2MSFTNGP12.phx.gbl...
>I have several labels and textboxes that are drawn to a tab page based on 
>certain criteria so these labels and textboxes can be drawn at different 
>points on the tab page.  I set the label and textbox names in the drawing 
>procedure.  Now what I need to do is to get the control's information on a 
>mouse down.
>
> Here is what I have:
>
> ////
> Private Sub tcGuard_MouseDown(ByVal sender as Object, ByVal e as 
> System.Windows.Forms.MouseEventArgs) Handles tcGuard.Mousedown  'tcGuard 
> is a tab control
>    Dim mouseLocale as new point(e.X, e.Y)
>    dim tName as String
>    dim cntrl as New Control
>    cntrl = tcGuard.GetChildAtPoint(mouseLocale)
>    tname = cntrl.Name
> End Sub
> \\\\
>
> Here is the error message I get:  Object reference not set to an instance 
> of an object.
>
> All I need to do at this juncture is get the name of the label or textbox 
> that the mouse clicked on.
>
> If I am doing this wrong, please let me know and thanks for any help you 
> can give.
>
> Brad
> 


Relevant Pages

  • Re: How can I format label name as I loop through records?
    ... I'm using a tab control to ... > identify all the potential subform records, ... > I have created small 'marker' labels above each tab and want to make ...
    (microsoft.public.access.formscoding)
  • Re: Asp.Net AJAX dynamically added Tab Control not displaying
    ... TabPanel assumes there's no active tab and it hides all the tabs at client ... protected void Page_PreRender ... Microsoft is providing this information as a convenience to you. ... does not control these sites and has not tested any software or information ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Subform trouble for New User
    ... control as suggested. ... I didn't use that field in the Subform Field Linker). ... The structure of this tab is ... continuous form.I have limited the fields in the continuous form to ...
    (microsoft.public.access.forms)
  • Re: Updating Label Caption
    ... I like the table idea to control the label's properties, ... I used the "refresh" thinking that I had to force a refresh to see the ... The labels are on frmProjectionReports form, ... Select on the tab index number to see if I can get it to work. ...
    (microsoft.public.access.formscoding)
  • Re: Tab Control
    ... here's the code on an Option Group control that changes ... to the corresponding index value of the tab control page you ... click to go to the first tab page, and set the button's OptionValue property ... i keep the list of available subforms in tbl00SubformReports, ...
    (microsoft.public.access.formscoding)