private void Cottage_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = "create cottage";
            richTextBox1.Text = "create Bob";
        }

So when I run the code what gets printed is Bob of course I knew this would happen from the moment I wrote the code but I do not know what to put instead, I want to be able to print both on two seperate lines also I will have many other buttons printing into this same RichTextBox so I need to know how to move from my curent line and print on the next line everytime I click on the button....Thank you :)

Also How would I make a If statement where if the button is clicked then it prints "Hola" into the richtextbox?

Recommended Answers

All 3 Replies

Try adding \n to your string. If that doesn't work try \r\n.

Also How would I make a If statement where if the button is clicked then it prints "Hola" into the richtextbox?

First step would be to create an event handler for the button click event. Then put the if statement in there.

Also note that a RichTextBox has an AppendText method
So you could build up your text, for example with StringBuilder, and append it to the RichTextBox.

Yes, I find that the AppendText method does work perfectly and "tinstaafl" thanks, found out what I was trying to do wouldve given me crazy syntax errors without the Event

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.