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

get reference of the containing form

Neo
I am trying to create a custom control, & in this control i need to access
the form where this control is added.
How can i do this.

- I tried to accept a new parameter in the constructor of this new control,
but then i can't drop the control onto the form.
- I don't want to drop the control onto the form & set the reference to the
form in a property of the control from code, because if i want to drop this
control 10 times in 10 forms, then this means that i will always have to set
the reference of the form in a property of this control.

I just want to access the form from my control & do not want to put ANY code
in the form (but only have to be able to drop this control on the form and
this will be enough)

How can i resolve my problem.
Nov 21 '05 #1
7 1119
Neo,

Do you mean that you want to set in your control method

Sub new
messagebox.show(me.parent.tostring) 'A stupid piece of code however just to
show how.
end sub

I hope this helps?

Cor
Nov 21 '05 #2
Neo
aaaaaggggh, silly me. never thought of looking for a property PARENT.
Excellent chum, thank you.
You have saved a lot of my development time.... I have been trying to rack
my brain on this.
looking for a simple solution but thinking too darn hard.

Thank you again.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:eM**************@TK2MSFTNGP11.phx.gbl...
Neo,

Do you mean that you want to set in your control method

Sub new
messagebox.show(me.parent.tostring) 'A stupid piece of code however just to show how.
end sub

I hope this helps?

Cor

Nov 21 '05 #3
Neo
For some odd reason i never got the PARENT or the PARENTFORM to work,
but found that the FindForm() method is what i need.
I think this is the ideal way of getting the form on which this control is -
cuz thats what the method says it does.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:eM**************@TK2MSFTNGP11.phx.gbl...
Neo,

Do you mean that you want to set in your control method

Sub new
messagebox.show(me.parent.tostring) 'A stupid piece of code however just to show how.
end sub

I hope this helps?

Cor

Nov 21 '05 #4
That can be when you use a webform
Nov 21 '05 #5
Cor,
That can be when you use a webform Huh?

Control.FindForm is a Windows Forms Control method & is used to find the
Form the control is on. For details see:

http://msdn.microsoft.com/library/de...dformtopic.asp

http://msdn.microsoft.com/library/de...arenttopic.asp
Are you perhaps think of Web Form's Control.FindControl?

http://msdn.microsoft.com/library/de...ntroltopic.asp

Hope this helps
Jay

"Cor Ligthert" <no************@planet.nl> wrote in message
news:e4****************@tk2msftngp13.phx.gbl... That can be when you use a webform

Nov 21 '05 #6
Jay,

You are right. I was answering this impulsive.

Because that I use and was thinking about that.

Cor
Nov 21 '05 #7
The last sentence is cryptic

Because that I use and was thinking about that.

Because that ( Me.FindControl("Form1")) I know the use for and I was
thinking about that.

Cor
Nov 21 '05 #8

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

Similar topics

2
by: Good Enchiladas | last post by:
While building on a class library for an object model, I get the above error message. The steps to recreate the problem are as follows: 1. Build a RootLevel.dll containing only this code: ...
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...
4
by: Holly Li | last post by:
Hi, Because of reuse, I need to mix C# project and VB.net project. To illustrate the problem, I have built 3 simple projects: 1) C# library--projc (has one class "Manager") 2) vb.net...
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: Ross McLean | last post by:
Hi all, I've been teaching myself C# for a new project at work. I have a bit of a background in c++ and java but never been what you could call a guru. I'm having some strange things happening...
0
by: Richard Gregory | last post by:
Hi, I have the wsdl below, for an Axis web service, and when I select Add Web Refernce in Visual Studio the proxy is missing a class representing the returnedElementsType (see reference.cs below...
3
by: nam23 | last post by:
Hi, I'd like to create a List containing all the checkboxes on a form. The thing is, I don't know how many checkboxes there might be. I thought perhaps I could use reflection to look at all of...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
jinu1996
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...
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...
0
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,...

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.