vb.netreturnsymbolslinefeed

VB.net Textbox, how to get Newline Symbol (little arrow, same as in enter key)


In Visual Basic.net I managed to get this little arrow symbol in the TextBox some time ago, but lost it.

Is this font dependent? I used Consolas and Courier New. Do i need a RichTextBox or something else?

I tried chr(10) and chr(13), environment.newline and vbLf, vbCr and what else but I'm lost.

I just want to have that special character to be visible for "debug purposes". My system is UTF capable.


Solution

  • The TextBox does not display unprintable characters, like most text editors can do.

    You can, however, simply insert the symbol yourself, be replacing each newline character with and a newline character.

    Example:

    Dim f = New Form()
    Dim txt = New TextBox() With { .MultiLine = True, .Dock = DockStyle.Fill}
    
    Dim text = <text>This is just
                     some multine text
                     to be displayed</text>.Value
    
    txt.Text = Regex.Replace(text, "(\n\r|\r|\n)", "↵$1")
    
    f.Controls.Add(txt)
    f.ShowDialog()
    

    Result:

    enter image description here