Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- namespace _01_V.Kursov_Proekt
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- int i = 0;
- if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
- {
- if (textBox1.Text == "")
- {
- errorProvider1.SetError(textBox1, "Please enter a name.");
- }
- if (textBox2.Text == "")
- {
- errorProvider1.SetError(textBox2, "Please enter a family.");
- }
- if (textBox3.Text == "")
- {
- errorProvider1.SetError(textBox3, "Please enter an EGN.");
- }
- }
- else
- {
- while (i == 0)
- {
- errorProvider1.Dispose();
- listView1.View = View.List;
- listView1.Items.Add(textBox1.Text);
- listView1.Items.Add(textBox2.Text);
- listView1.Items.Add(textBox3.Text);
- i++;
- }
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- StreamWriter writer = new StreamWriter("D:\\data.txt",true);
- using (writer)
- {
- foreach (ListViewItem item in listView1.Items)
- {
- writer.WriteLine(item.Text);
- }
- writer.WriteLine();
- }
- textBox1.Clear();
- textBox2.Clear();
- textBox3.Clear();
- listView1.Clear();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement