List data
Now in my program in C # that mimics lan-messenger, I need to show people who are currently online with one remote hostname on each line. However, the problem is that for this I am using the function
//edited this line out, can't find a .Append for listBox or .AppendLine
//listBox.Append(String );
listBox.Items.Add(new ListItem(String));
This displays carriage returns and newline characters (i.e. ... \ r and \ n) as small rectangular rectangles at the end of the hostname. How can I get rid of this?
0
a source to share
4 answers
Another option is to consider creating an extension method for the custom finish you are trying to achieve.
/// <summary>
/// Summary description for Helper
/// </summary>
public static class Helper
{
/// <summary>
/// Extension Method For Returning Custom Trim
/// No Carriage Return or New Lines Allowed
/// </summary>
/// <param name="str">Current String Object</param>
/// <returns></returns>
public static string CustomTrim(this String str)
{
return str.Replace("\r\n", "");
}
}
Your line of code looks like this:
listBox.Items.Add(new ListItem(myString.CustomTrim());
+1
a source to share
It looks like you are using some kind of TextBox in one line mode. If so, activate TextBox.Multiline .
0
a source to share