Doubt with textbox

Asked

Viewed 58 times

0

I’m trying to create a screen of log using a textbox in C#.

At certain points in the programme, I would like to insert a line in this textbox. Take the example of:

Linha 1> Realizando inserção..
Linha 2> Dados inseridos..
Linha 3> Pedido Realizado.

I tried to do it like this:

txtBoxLog.Text = "Realizando inserção..\n";

But for each line of this program, instead of inserting a new line in the textbox, it erases what is written and puts the new value.

Sincerely yours truly, Yves Fernandes

1 answer

1


To TextBox is configured as Multiline? if yes just do this;

txtBoxLog.Text += "Realizando inserção..\n";

The attribution command += concatenates the current content with the previous content.

  • I think your "question" would already answer the problem, which apparently is the same disabled multiline.

  • @Diegofelipe Even if the multiline had activated, it is deleting the previous value and setting a new one using Text = "", the right is to use the way it is in the answer.

  • Felipe, Good morning. Thanks for the answer, she answered my question. I will mark as answered. My textbox is multiline and only with the n line jump?

  • Yes it would add a line break but as you were using the = only it replaces the previous content.

  • Show!. Thank you all very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.