samedi 22 avril 2017

C# - textbox, buttons and if statement

Okay so here's what I want to do.

I have a textbox. In that textbox I write Human. Then I click a button, and if the word is human, then on a richtextbox, the word human will appear.

So that's basically what I want to do.

Here's the code I've tried.

private void button3_Click(object sender, EventArgs e)
    {
        if (textBox4.Text)
        {
            richTextBox1.Text = "human";
        }
    }

    private void textBox4_TextChanged(object sender, EventArgs e)
    {
        string value = textBox4.Text;
    }

This is what I've tried. I tried making the textbox into a string so I could use it in the if statement, but it didn't work, so instead I used texbox4.text, but it is still wrong.

I'm still a newbie in c#, so some nice advices would be appreciated.

Cheers!

Aucun commentaire:

Enregistrer un commentaire