Failing to add a new line in Windows Forms C#

261 Views Asked by At

I really appreciate your help and contribution in advance, I am training on C# home and it's been great way to do something with home time: I am trying to append a string of text to txtCollectionBox from txtNoteBox and a new line at the end of each string of text from txtNoteBox. But it's appending on the same line, not a new line - does anyone know why?

private void btnAddNote_Click(object sender, EventArgs e)
{
    if (txtNoteBox.Text == "")
    {
        MessageBox.Show("Please Add a Note");
    }
    else
    {
        txtCollectionBox.AppendText("[*] " + txtNoteBox.Text + "  ." + "\n");
        txtNoteBox.Clear();
    }
}
1

There are 1 best solutions below

1
Mahmood Darwish On

Try removing \n and replacing it withEnvironment.NewLine. (or maybe it is System.Environment.NewLine I don't remember.)