473,809 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to access form1 controls from form2

1 New Member
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 4072
Gopi
5 New Member
hi,
just create the object for form1 and objectname.cont rolname

and there is tutorial here on this site

http://www.dreamincode.net/forums/to..._1#entry482260
Mar 30 '12 #2
Mustafa
1 New Member
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)
{
InitializeCompo nent();
textBox1.Text = Sum.ToString();
}
I Hope That Help You
Apr 11 '12 #3
RhysW
70 New Member
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
1758
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 String Dim myDataListItem As DataListItem Dim myDatagridItem As DataGridItem Dim myCheckBox As CheckBox
5
14182
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 variable in form2. Is there a simple method (in VSexpress2005) to get that specific variable in form2? TIA,
2
2846
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 help me with some code samples :) Thanks!
9
1622
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 fields are transfered to some label fields to frmVerify. Sounds easy but I keep getting "System.Windows.Forms.Groupbox' does not contain a definition for 'verifyForm' Here is that part of the code: private void btnSubmit_Click(object sender,...
1
2251
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 "False" only. please see the following code where i did wrong. I ahve created A Visual C# .Net project. for that i ahve added Form2 now my project contains Form1 and Form2. In Form1 i have placed Control "RadioButton1"
5
3129
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 accesses them? My current code is as follows: Partial Public Class indextest : Inherits System.Web.UI.Page Private rowcount As Integer = 0 Protected Sub Page_Load(ByVal sender As Object, ByVal e As
1
1546
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 table. The problem is the datagridview is unavailable in form2. I donno how to link datagridview from form1 and form2 or either way.I am using c#.net
10
3552
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. public string combostring {
0
11183
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 about how to go about doing this. This tutorial is intended to show you more "correct" ways of passing data between forms. The scope of this tutorial is limited to passing data between forms. We will look at both properties and custom events, but...
1
2964
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 closes and form1 is again enabled. its my intention to do. so any one pleas help me in this regard please send me the sample code to do. Thank you.
0
10640
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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
10387
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
10120
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4332
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
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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.