473,405 Members | 2,187 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,405 software developers and data experts.

how to access form1 controls from form2

hi friends
i want a small help

in my project

in form1 i have two textboxes and a button
in form2 one textbox
actually i want addition calculation
enter two values from two textboxes which are in form1
by clicking button1
i want result in form2 textbox
Mar 30 '12 #1
3 4057
Gopi
5
hi,
just create the object for form1 and objectname.controlname

and there is tutorial here on this site

http://www.dreamincode.net/forums/to..._1#entry482260
Mar 30 '12 #2
Hi:
Try This Code

At Form1 At Buttone1
{
Int Sum = Convert.ToInt16(textBox1.Text) + Convert.ToInt16(textBox2.Text);
Form2 Frm = new Form2(Sum);
Frm.ShowDialog();
}

At Form2
public Form2(int Sum)
{
InitializeComponent();
textBox1.Text = Sum.ToString();
}
I Hope That Help You
Apr 11 '12 #3
RhysW
70
I suggest instantiating form2 on form1 like so:
Expand|Select|Wrap|Line Numbers
  1. Form = new form1();
on form 2 you can set it so that the text-boxes etc are set to public not private then you can access what is in there or set what should be in there by doing something similar to the following:
Expand|Select|Wrap|Line Numbers
  1. Form.tbx_Name.Text
you can either get whats in there or set what is in there depending on what it is you want to do, hope this helps!
Apr 12 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: bill yeager | last post by:
I did some more debugging and found the following: 1) I placed the following code in the button event just to see if I could cycle thru the datagrid control collection: <code> Dim strhello As...
5
by: John | last post by:
Hi, I can't find a simple example for a simple(?) problem. I am working on an application with a variable in form1, that variable is needed in form2 for a calculation but i can't get that...
2
by: Svein Erik | last post by:
C# 2.0 How can i update my progress bar on Form1, from Form2? Form 2 contains a button that is supposed to update the progressbar on Form1 by 5 in value. I can't find out how to do this, please...
9
by: wanyok | last post by:
I thought I had it figured out but I'm still getting errors :( I would appreciate any help I could get. I have two forms: Form1 and frmVerify. Once the info gets submitted on Form1 its text...
1
by: Suma | last post by:
Hi, i have a problem with the controls .i have to validate Form1 Radio button option is checked or Not in the Form2. even after checking the radio button also in FOrm2 it is always taking as...
5
by: Nathan Sokalski | last post by:
I have a FormView control in which I use a PagerTemplate. I am having trouble accessing the controls in the PagerTemplate. How do I access them, and in what event should I put the could that...
1
by: ashwinigopi | last post by:
I have two forms, form1 & form 2. Form1 has datagridview. I am not supposed use any sql command in form1. So i added form2 and wrote the sql commands using stored procedures to get the data from the...
10
maheshwag
by: maheshwag | last post by:
I have to form in my application form1 and form2 form1 having combobox and form2 having textbox I wants to retrieve the value of combobox to textbox by setting property like below. ...
0
Curtis Rutland
by: Curtis Rutland | last post by:
This question is asked practically every day in the C# Forum: "how do I get a value from Form1 to Form2?" or the other way around. There is a shocking amount of bad advice out there on the internet...
1
by: Anil D | last post by:
Hi, I have two forms(form1 and form2). I placed a button in form1 to redirect to form2. now my question is if i click the button form2 is displayed and form1 is disabled and if i close the form2 it...
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
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
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.