using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApp2 { public partial class Output_statistic : Form { public Output_statistic() { InitializeComponent(); string path = @"camera" + this.Camera1.SelectedIndex +"_statistic.txt"; string text = null; if (File.Exists(path)) { text = System.IO.File.ReadAllText(path, Encoding.Default); } switch (this.Camera1.SelectedIndex) { case 0: textBox1.Text = text; break; case 1: textBox2.Text = text; break; case 2: textBox3.Text = text; break; case 3: textBox4.Text = text; break; case 4: textBox5.Text = text; break; case 5: textBox6.Text = text; break; case 6: textBox7.Text = text; break; case 7: textBox8.Text = text; break; } } private void tabControl1_Selected_Change(object sender, EventArgs e) { string path = @"camera" + this.Camera1.SelectedIndex +"_statistic.txt"; string text = null; if (File.Exists(path)) { text = System.IO.File.ReadAllText(path, Encoding.Default); } switch (this.Camera1.SelectedIndex) { case 0: textBox1.Text = text; break; case 1: textBox2.Text = text; break; case 2: textBox3.Text = text; break; case 3: textBox4.Text = text; break; case 4: textBox5.Text = text; break; case 5: textBox6.Text = text; break; case 6: textBox7.Text = text; break; case 7: textBox8.Text = text; break; } } } }