0

Which element is good, if I get continouous text from my COM and I want display it in a Box,like textBox.

I want keep the old text but add in a new line like:

COM Data1: 0xFF 14:10 PM
COM Data1: 0xA3 14:10 PM
COM Data1: 0x12 14:11 PM
....

If I use a textbox and do this

txtbox.Text = comData;

it replace my older text.

Thx

user2261524
  • 415
  • 3
  • 10
  • 17

2 Answers2

3

use a listbox or a listview,

add element one by one.

So for example in a loop you can do

for each item in ComData.item

listbox1.add = item

loop

and that would add a line below the last.

AltF4_
  • 2,312
  • 5
  • 36
  • 56
2

You can do:

txtbox.Text = txtBox.Text + Environment.NewLine + comData;

You can use StringBuilder as well for string concatenation like:

StringBuilder sb = new StringBuilder();

public void yourMethod()
{
  sb.Append(comData);
  sb.Append(Environment.NewLine);
  txtBox.Text = sb.ToString();
}

(Why use StringBuilder See: Stringbuilder vs String.Concat)

Community
  • 1
  • 1
Habib
  • 219,104
  • 29
  • 407
  • 436