I have built a library that dumps most of its debug text using Console.WriteLine();
I am now I am the process of using the library in a Windows Forms Application, and s
Another, probably cleaner way to do this is to extend TextWriter with your own that logs to wherever you'd like it to.
Note: I have not tested this.
public class ListBoxWriter : TextWriter
{
private ListBox list;
private StringBuilder content = new StringBuilder();
public ListBoxWriter(ListBox list)
{
this.list = list;
}
public override void Write(char value)
{
base.Write(value);
content.Append(value);
if (value == '\n')
{
list.Items.Add(content.ToString());
content = new StringBuilder();
}
}
public override Encoding Encoding
{
get { return System.Text.Encoding.UTF8; }
}
}