how to reference the form?

  • Thread starter Thread starter rua17
  • Start date Start date
R

rua17

I'm creating a special button control that creates a log in the database
every time is touched.

I need to log whe name of the button and the name of the form that contains
it

In some cases the button could be contained by the form, in some cases it
could be contained by a pageframe that is contained by the form...

How can I reference the form name for this case??? is there any property
that has the container of the button?

thanks
 
Yes, each control has a property called Container that returns the container
(e.g. form, another control...) of that control. You can traverse up the
list of Containers (i.e. find the container of your button, then find the
container of that container and so on until you get null) until you find the
parent of all the controls which should be a form in a simple windows forms
app.
 
Actually, there is also a Parent property you can use. I'm not sure exactly
what the difference is though...
 
I had the same suggestion as Matt. You could make a short recursive method
to look for the parent of the current control until you find a control of
the type you are looking for.

-Darrin
 
Button.Parent - Gives you the container control and Forms is a container
control. Hope that helps.
--------------------
From: "rua17" <[email protected]>
Subject: how to reference the form?
Date: Mon, 17 Nov 2003 12:27:04 -0600
Lines: 15
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <#[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: ip251-10.ct.co.cr 196.40.10.251
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:199914
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

I'm creating a special button control that creates a log in the database
every time is touched.

I need to log whe name of the button and the name of the form that contains
it

In some cases the button could be contained by the form, in some cases it
could be contained by a pageframe that is contained by the form...

How can I reference the form name for this case??? is there any property
that has the container of the button?

thanks


Rakesh, EFT.

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
Back
Top