473,761 Members | 8,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

load form and passing parameters to it

Hi
Does anyone know how could I load a form from another and send some
parameters to it?
Is there a way to identify by name instances of same form?
Thx
Nov 15 '05 #1
6 27028

"Jared" <j.*@globalnet. net> wrote in message
news:bh******** **@ls219.htnet. hr...
Hi
Does anyone know how could I load a form from another and send some
parameters to it?
A Form is just like any other class/object in .NET.

Create some private member variables and expose them as
properties with getters/setters.

In your FormA, create FormB and set the properties, and then
Show() the form.
Is there a way to identify by name instances of same form?


No. This is not VB6. There are types/objects and instances
of types/objects.

When you create an instance of FormB,you must maintain that
reference just like any other object, if you wish to call
methods, get/set properties, etc in the future.

-c
Nov 15 '05 #2
"Jared" <j.*@globalnet. net> wrote:
Does anyone know how could I load a form
from another and send some parameters to it?


Give your form a new constructor with parameters.

public Form1(string strTitle)
{
// Required for Windows Form Designer support
InitializeCompo nent();

this.Title = strTitle;
}

P.

--
www.CL4.org
Nov 15 '05 #3
Another option would be to create a parameterized constructor for the form.

Jeremy Wilde

"Chad Myers" <cm****@N0.SP.4 M.austin.rr.com > wrote in message news:3E******** **********@twis ter.austin.rr.c om...

"Jared" <j.*@globalnet. net> wrote in message
news:bh******** **@ls219.htnet. hr...
Hi
Does anyone know how could I load a form from another and send some
parameters to it?


A Form is just like any other class/object in .NET.

Create some private member variables and expose them as
properties with getters/setters.

In your FormA, create FormB and set the properties, and then
Show() the form.
Is there a way to identify by name instances of same form?


No. This is not VB6. There are types/objects and instances
of types/objects.

When you create an instance of FormB,you must maintain that
reference just like any other object, if you wish to call
methods, get/set properties, etc in the future.

-c


Nov 15 '05 #4
to extend a bit:
What does referencing forms means to performance and
memory consumption? (If I have 10 forms loaded at once,and each of them
references one form and one or more classes,does this mean that each
referenced form and class is loaded into memory?)
Nov 15 '05 #5

"Jared" <j.*@globalnet. net> wrote in message
news:bh******** **@ls219.htnet. hr...
to extend a bit:
What does referencing forms means to performance and
memory consumption? (If I have 10 forms loaded at once,and each of them references one form and one or more classes,does this mean that each
referenced form and class is loaded into memory?)


If you have instances of a class or form created, then yes,
they take up memory.

Depending on how large your forms or classes are, this isn't
a lot of memory, really. Most classes are pretty small in
size. Forms are pretty small as well unless you have a lot
of embedded images and whatnot.

-c
Nov 15 '05 #6
Chad Myers <cm****@N0.SP.4 M.austin.rr.com > wrote:
A Form is just like any other class/object in .NET.


It always amazes me the number of people who just don't seem to get
this. Personally I think the problem is that people dive straight into
Windows Forms without learning the basics first. I always recommend
learning a new language in the simplest way possible - which in C# is
by writing console apps. I'm sure if more people wrote console apps and
"played" with the language (and libraries) that way, they'd be less
confused when learning Windows Forms later.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #7

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

Similar topics

5
3744
by: isaacrajan | last post by:
Hello, I have a form A in my ADP project. The record source of A has input parameters. I need to open form A from three different forms X, Y and Z. When I open A from form X, I want it to take input parameters from form X. When I open A from form Y, I want it to take input parameters from form
2
3042
by: Andrew Chanter | last post by:
I am developing my first ADP client for a SQL db, after having used mdb's as clients in numerous applications previously. I have found that theoretically the Input Parameters property of a form in an adp and its method of therefore enabling a form to be connected to a procedure that requires parameters is really nifty. However in practice I am finding a number of annoying issues with this, most particularly that the adp seems to have...
2
13937
by: Martin Maat | last post by:
Hi, I am trying to create a plug-in assembly without the need to register it in the GAC. Reflection should help me out here. I got this far: private void button1_Click(object sender, System.EventArgs e) { Assembly engine = null; AssemblyName assemblyName = new AssemblyName(); assemblyName.CodeBase = assemblyPath + @"Engine.dll";
0
2525
by: Frank 'Olorin' Rizzi | last post by:
Hello everyone. This is quite convoluted, but I'll try to make it simple. I have a couple of bottom-line questions (I guess): 1~ what happens between the Page_Load routine in the code behind of an aspx page and the presentation of the page to the user? 2~ is it true that the engine takes data from the Request.Form and puts them
1
1022
by: Reza Nabi | last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a placeholder dynamically based on the ctlName querystring passed in the URL. Webform (LoadCtl.aspx) also passes a variable (targetId) in to the usercontrol (IntergySite.aspx) by calling its setter method. Currently, I am using if-then-else and hardcoded the User Control Object to do casting and call the setter method. Question: Is there any way I could load,...
4
4012
by: MicroMoth | last post by:
Hi, I'm trying to write a update method, in which when the user clicks the update button the update method is passed 10 form fields. Then a update SQL is run to update the database. My question is whats the best way to pass large numbers of parameters into a method. Ten seems a large number to be passing into and out of a method. Stephen
2
1558
by: Jerry Spence1 | last post by:
One way of passing data to a thread is to encapsulate the thread inside a class. However, I can't refer to my main form objects from within the class/thread as it says "Reference to a non-shared member requires an Object reference". How do I refer to items such as Textbox1.text etc on my main form? -Jerry
10
15329
by: sara | last post by:
Hi - I have been struggling with solution ideas for this now for almost 2 weeks, and have not been able to figure this out. I have a user who creates a Purchase Order (tblPOData). In some circumstances, this or another user must create an invoice to go with the PO (I know - that makes no sense, but this is the business case). I have the user go to a form to create the invoice:
2
2781
by: pat.saunders | last post by:
Hi, I am using Visual Studio 2005 and am using Visual C#. I notice that the program.cs creates an instance of a form and runs it. I have a PictureBox in the form and a Class File x.cs and in the Class file x.cs want to access some of the picturebox parameters e.g size but I do not have access to these parameters. I could write a function in form.cs to return these parameters but as I don't have access to an instance of form I cannot call...
0
9522
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9948
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6603
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5215
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3866
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 we have to send another system
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.