Locke Locke - 2 years ago 155
C# Question

How to Avoid LineBreaks in Winforms TextBox

Im learning c# at the moment, and I would like to add text to a TextBox.
I am appending Text with TextBox.AppendText() method:

public delegate void WriteToLogEventHandler(object sender, EventArgs e);
private void WriteToLog(object sender, EventArgs e)
{
if (InvokeRequired)
Invoke(new WriteToLogEventHandler(WriteToLog), new object[] { sender, e });
else
{
textBox_Messages.AppendText((e as WriteToLogEventArgs).Message);
}

}


But I don't want the Lines to automatic line break, I want the TextBox to scroll horizontal. I already tried the TextBox Scrollbar Property "vertical", "horizontal" and "both"

but the Textbox looks always like this:

enter image description here

Is there a way to automatically make the textbox horizontal scrollable

excuse my english
Thanks Locke...

Answer Source

Try setting the WordWrap property to false along with having both scroll bars.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download