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

How can I reference a Windows Form

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

is it possible? any idea

thanks
Nov 16 '05 #1
1 1421
Hi Oney,

Define a special constructor for frm2 that takes a Form reference.

public class Form2 : Form
{
Form1 frm1;

public Form2() {}
public Form2(Form1 frm)
{
frm1 = frm;
}

public void SomeMethod()
{
// do something with frm1, which is a reference to Form1
}
}

Then when you instantiate Form2, call it something like this:

frm2 = new Form2(this);

As a matter of proper coding style, don't expose your controls publicly.
Instead, define public properties and methods that encapsulate the internal
state of your form.

Joe
--
Joe Mayo, Author/Instructor
Need C#/.NET training?
visit www.mayosoftware.com
C# Tutorial - www.csharp-station.com

"Oney" <oz*********@yahoo.com> wrote in message
news:cc**************************@posting.google.c om...
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

is it possible? any idea

thanks

Nov 16 '05 #2

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

Similar topics

3
by: Andreas Kviby | last post by:
I have a HTML-form that I need to be able to POST from my VB.NET client application and store the resulting XML in a STRING or XML-document. This is the HTML-form code: <form name="form1"...
2
by: Mark D | last post by:
Hi Relative vb.net newbie here... I have a Windows Form application with a few subroutines in a separate module. From one of the subroutines, I want to get the value of a label or text box on...
4
by: Steven | last post by:
Hi, I have a database table field to store the form name, I want to create the particular windows form by using the value that read from that DB field. For examples, the table field has a value...
2
by: Alan | last post by:
I have created a class library say, EmployeeDataDLL.dll. This is a data access to the backend database. How do I create an object of the class inside this dll from a Windows form ?
9
by: | last post by:
Hi How to get a reference to main form in a Windows Form 2.0 Application? I'm making a a library and I need a reference to the main form of the application that is using that library. TIA
1
by: Pumpkin Carver | last post by:
I have a form that has a listview on it and a serious of strings in the listiew. When i doubel click on the listview item it opens a new form and displays the text that i pass to the constructor....
3
by: bsturg21 | last post by:
Hello, I have a windows form that has a series of linklabels on it, and I need to have each linklabel, when clicked, open a separate windows form that has a single paramter passed into it. The...
4
by: =?Utf-8?B?VGlhZ28gTWFycXVlcw==?= | last post by:
Hi all, I created a windows form, and I want to use it on other applications. To do that I think that it would be better to create a dll and on the new applications create a reference to it. It...
2
by: danphillips1977 | last post by:
Hopefully this hasn't been asked already - apologies if so I have a Windows Form running inside C# - built using the form designer I've built a number of methods inside the form Events which I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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?
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...

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.