what is the code for showing the button_Click event in a text box.....?

Recommended Answers

All 6 Replies

Hi MaiHunDown, welcome here!
Rather strange question.
What do you mean?
A TextBox has a Click or MouseClick event.
Do you want to show some info in a textbox after clicking a button?

Yes I want to show some info in a textbox after clicking a button.

Thanks

In the Click event of a button you could set the Text property of your TextBox.
Like so:

private void button1_Click(object sender, EventArgs e)
        {
            this.textBox1.Text = "Hello world!";
        }
commented: Helpful, to the point :) +1

Plz help
There aren two button and one textBox in a form.I want to show information in textBox when I click 1st button info is showing in texBox but when I click 2nd button the earlier text from textBox is going unvisible or erase?, I don't want it to erase.

Then do it like this:

this.textBox1.Text += "Hello world!";

or

this.textBox1.Text = this.textBox1.Text + "Hello world!";

The plus operator will append your new string to the textstring already in the textbox.

Check this code i hope its solve your problem

private void button1_Click(object sender, EventArgs e)
      {
     textBox1.AppendText("I Love Allah!");
      }

 private void button2_Click(object sender, EventArgs e)
      {
      textBox1.AppendText("I Love Islam!");
      }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.