FORM1 contain 3 textbox,1 button and FORM2 also contain 3 textbox, 1 button. I want to do....
when user fill FORM1 textboex and click button1 then all entries should be shown on FORM2. and vice versa plz help me.i used this code its working very good. when i pass value in form2 textboxes its show on form1 textbox. but i want to do, if textbox of form1 is already fill then form2 textboex should also shws form1 textbox value. plz help me
Expand|Select|Wrap|Line Numbers
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace punchout
- {
- public partial class Form1 : Form
- {
- public string RichText { get { return richTextBox1.Text; } set { richTextBox1.Text = value; } }
- public string txtbox1 { get { return textBox1.Text; } set { textBox1.Text = value; } }
- public string txtbox2 { get { return textBox2.Text; } set { textBox2.Text = value; } }
- public string txtbox3 { get { return textBox3.Text; } set { textBox3.Text = value; } }
- public Form1()
- {
- InitializeComponent();
- }
- private void richTextBox1_Click(object sender, EventArgs e)
- {
- var form2 = new Form2(this);
- form2.Show();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace punchout
- {
- public partial class Form2 : Form
- {
- private Form1 parentForm;
- public Form2(Form1 form)
- {
- InitializeComponent();
- this.parentForm = form;
- }
- private void Form2_Load(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- //if (this.parentForm == null)
- //{
- // return;
- //}
- parentForm.RichText = textBox1.Text + Environment.NewLine + textBox2.Text + Environment.NewLine + textBox3.Text;
- parentForm.txtbox1 = textBox1.Text;
- parentForm.txtbox2 = textBox2.Text;
- parentForm.txtbox3 = textBox3.Text;
- this.Close();
- }
- }
- }