Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Display value from Child form to parent TextBox

Posted on 2008-09-29
4
Medium Priority
?
427 Views
Last Modified: 2013-12-17
Hi,
I have winForm (form1 and form2)
On Form1 I have Textbox (txtBox1 and form2  txtbox2 )
On click of button I load form2  ie   form2.showDialog()   ..I have to display value entered in Txtbox2 in form1 textbox (txtbox1)
NOTE : Form1 would be open first.. (How can i reload the form1 back again to show the txtBox2 value)
0
Comment
Question by:dotnet0824
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 14

Expert Comment

by:Jai S
ID: 22595681
say you have a button btnSendValuesToForm1...
here will be the code to displau the textbox2 value in textbox1 of form1

onclick="javascript:parent.document.getElementById('txtbox1').value = document.getElementById('txtbox2').value;window.close();return false;"

if its a server side control then instead of onclick you put onClientClick...which will generate teh onclick event for that button...
0
 

Author Comment

by:dotnet0824
ID: 22595704
Hi, This is windowsForm applicatoin.... Pls I am looking for Code
0
 
LVL 14

Accepted Solution

by:
Jai S earned 2000 total points
ID: 22595901
oops sorry...
here it is...

//FORM 1 button click event
        private void button1_Click(object sender, EventArgs e)
        {
            Form2 frm2 = new Form2();
            frm2.ShowDialog();
            textBox1.Text = frm2.textvalue;
        }
 
//Form2 button click event and global variable for 
        public string textvalue;
        public Form2()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            textvalue = textBox1.Text;
            this.DialogResult = DialogResult.OK;
 
        }

Open in new window

0
 
LVL 11

Expert Comment

by:ladarling
ID: 22596923
The click event for your Form2 button should be somthing like:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form1.TextBox1.Text = Me.TextBox2.Text
Me.Close()
End Sub
You can refer to Form1, in this case, by its class name in VB.NET.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question