473,395 Members | 1,530 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,395 software developers and data experts.

how to reference the form?

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
Nov 15 '05 #1
5 1500
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.

"rua17" <ru***@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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

Nov 15 '05 #2
Actually, there is also a Parent property you can use. I'm not sure exactly
what the difference is though...

"rua17" <ru***@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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

Nov 15 '05 #3
Actually, that was wrong, my fault. Use the parent property instead.

"Matt Burland" <an*******@discussions.microsoft.com> wrote in message
news:uJ**************@TK2MSFTNGP11.phx.gbl...
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.

"rua17" <ru***@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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


Nov 15 '05 #4
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
"rua17" <ru***@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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

Nov 15 '05 #5
Button.Parent - Gives you the container control and Forms is a container
control. Hope that helps.
--------------------
From: "rua17" <ru***@hotmail.com>
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: <#0**************@tk2msftngp13.phx.gbl>
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!tk2msftn gp13.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

Nov 15 '05 #6

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

Similar topics

4
by: Cybertof | last post by:
Hello, What is the difference between : - adding a new reference to a namespace within the SolutionExplorer (right click, Add Reference...) - adding a new reference with the 'using' keyword in...
12
by: Bill Todd | last post by:
Form B needs to call a public method of Form A. How can form B get a reference to the instance of Form A using its name or any other method? Is there a collection of form instances that can be...
1
by: Oney | last post by:
How can I reference a Windows Form In details; I created two Form (frm1,frm2) I want to reach frm1 controls from frm2 in runtime. So I have to reference frm1 by the way there is no mdi form ...
3
by: Giovanni Bassi | last post by:
Hello all, I have prepared a simple procedure to open forms only once. Here it is: -//- Private Sub OpenChildForm(ByRef objFormToOpen As System.Windows.Forms.Form, ByVal TypeToCreate As...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
16
by: Paul S. Natanson | last post by:
What is a Null Reference error and how do I fix it? My newly installed VB.Net2003 gives me a "Microsoft Development Environment" error message box EVERY time I try to run/start ANY project -...
16
by: John | last post by:
Hi I have posted this question several times but have received no reply. I have a main form which contains a panel which in turn contains a child form, like this; MainForm->MyPanel->ChildForm....
3
by: Ann Huxtable | last post by:
I wrote a method that accepted a form. The signature was as ff: void foo(ref Form frm) ; I had to remove the ref keyword to get it to compile. Any idea why? I though forms would be passed by...
10
by: Richard Lewis Haggard | last post by:
I've created in form that has tab controls that contain tab controls that host user controls on each tab page. It compiles and runs just fine but the designer view fails with a "A circular control...
9
by: Brad Pears | last post by:
I have the following code that references a "textbox" on a form. I want to pass the value of this textbox to a stored procedure as a parameter. This code is located on a different form obviously. I...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.