简体   繁体   中英

Refresh the Form in windows application using c#

Again I'm in need of ur help.Here is the process

1.I Have one form with a textbox

2.In keyDown event While pressing F1 an another form opens.

3.In the second form,i have a richtextbox.I want to edit tat richtextbox and pass that value to form1's textbox while clicking a button in form2.

Form1 Code:

private void Export_Load(object sender, EventArgs e)
    {
        textBox1.Text = "hai hello welcome to chennai";
    }private void textBox1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode ==Keys.F1)
        {
            rchbox rch = new rchbox();
            rch.Show();
            rch.richTextBox1.Text = textBox1.Text;
        }
    }

Form2 Code:

public rchbox()
    {
        InitializeComponent();
    }
    Export ex = new Export();
    Class1 c = new Class1();
    private void button1_Click(object sender, EventArgs e)
    {
        c.txt = richTextBox1.Text;
        ex.textBox1.Text = richTextBox1.Text;
        ex.textBox1.Refresh();
        ex.Refresh();
        ex.Invalidate();
       // ex.textBox1.Invalidated();
        this.Close();

    } 

I have found the problem that the form1 is not refreshed.i have even tried by calling refresh method. Can any one tell me.

You've created a brand new instance of the Export form, which you never show.
You aren't changing the existing instance.

Instead, you need to change the second form to take the existing Export instance as a constructor parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM