c# - What is a good way to direct console output to Text-box in Windows Form? -
in c#, way direct console output text-box in windows form?
if have existing programme has console.writeline , need overload function in windows form text-box?
create text author writes text box:
public class textboxwriter : textwriter { textbox _output = null; public textboxwriter (textbox output) { _output = output; } public override void write(char value) { base.write(value); _output.appendtext(value.tostring()); } public override encoding encoding { { homecoming system.text.encoding.utf8; } } }
and redirect console output writer:
//... public form() { initializecomponent(); } private void form_load(object sender, eventargs e) { console.setout(new textboxwriter(txtconsole)); console.writeline("now redirecting output text box"); }
c# textbox
No comments:
Post a Comment