private void Form1_Load(object sender, EventArgs e) { TextWriter _writer = new TextBoxStreamWriter(outputTB); // Redirect the out Console stream Console.SetOut(_writer); Console.WriteLine("Welcome to CubeBot CP! Console output will be redirected here unless disabled."); }
private void guna2Button1_Click_1(object sender, EventArgs e) { if (guna2Button1.Checked == false) { guna2Button1.Text = "Disable Output (Speeds Things Up)"; // Instantiate the writer TextWriter _writer = new TextBoxStreamWriter(outputTB); // Redirect the out Console stream Console.SetOut(_writer); Console.WriteLine("Console output is now set to textbox."); } else { guna2Button1.Text = "Enable Output (Useful for debugging)"; StreamWriter standardOutput = new StreamWriter(Console.OpenStandardOutput()); standardOutput.AutoFlush = true; Console.SetOut(standardOutput); } }