private void buttonInserisci_Click(object sender, EventArgs e) { int num = Convert.ToInt32(textBoxValori.Text); Vector.getInstance().addOrd(num); listValoriArray.DataSource = Vector.getInstance().getArray(); }
private void apriToolStripMenuItem_Click(object sender, EventArgs e) { Vector.getInstance().clear(); int i = 0; String line; int num; try { //Pass the file path and file name to the StreamReader constructor StreamReader sr = new StreamReader(OpenFile()); //Read the first line of text line = sr.ReadLine(); //Continue to read until you reach end of file while (line != null) { try { num = System.Convert.ToInt32(line); Vector.getInstance().addOrd(num); i++; line = sr.ReadLine(); } catch (Exception a) { } } //close the file sr.Close(); Console.ReadLine(); } catch (Exception a) { MessageBox.Show("Exception: " + a.Message); } finally { Console.WriteLine("Executing finally block."); } //listValoriArray.DataSource = Vector.getInstance().getArray(); string str = ""; foreach (int b in Vector.getInstance().getArray()) { str += Convert.ToString(b) + "\n"; } rtb.Text = str; }
private void buttonImporta_Click(object sender, EventArgs e) { int i = 0; String line; int num; richTextBox1.Text = ""; try { //Pass the file path and file name to the StreamReader constructor StreamReader sr = new StreamReader(OpenFile()); //Read the first line of text line = sr.ReadLine(); //Continue to read until you reach end of file while (line != null) { try { richTextBox1.Text += line + "\n"; num = System.Convert.ToInt32(line); Vector.getInstance().addOrd(num); i++; line = sr.ReadLine(); } catch (Exception a) { MessageBox.Show("Errore"); } } //close the file sr.Close(); Console.ReadLine(); } catch (Exception a) { MessageBox.Show("Exception: " + a.Message); } finally { Console.WriteLine("Executing finally block."); } listValoriArray.DataSource = Vector.getInstance().getArray(); }