Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. namespace WindowsFormsApplication2
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.        
  21.  
  22.        
  23.  
  24.         private void radioButton1_CheckedChanged(object sender, EventArgs e)
  25.         {
  26.             if (radioButton1.Checked == true)
  27.             {
  28.                 string input = radioButton1.Text;
  29.                 File.AppendAllText("zapis.txt", input + Environment.NewLine);
  30.                 StreamWriter zapis = new StreamWriter("A");
  31.                 zapis.Close();
  32.  
  33.  
  34.             }
  35.         }
  36.  
  37.         private void radioButton2_CheckedChanged(object sender, EventArgs e)
  38.         {
  39.             if (radioButton2.Checked == true)
  40.             {
  41.                 string input = radioButton2.Text;
  42.                 File.AppendAllText("zapis.txt", input + Environment.NewLine);
  43.                 StreamWriter zapis = new StreamWriter("B");
  44.                 zapis.Close();
  45.             }
  46.         }
  47.  
  48.         private void radioButton3_CheckedChanged(object sender, EventArgs e)
  49.         {
  50.             if (radioButton3.Checked == true)
  51.             {
  52.                 string input = radioButton3.Text;
  53.                 File.AppendAllText("zapis.txt", input + Environment.NewLine);
  54.                 StreamWriter zapis = new StreamWriter("C");
  55.                 zapis.Close();
  56.             }
  57.         }
  58.  
  59.         private void button1_Click_1(object sender, EventArgs e)
  60.         {
  61.             string[] lines = File.ReadAllLines("zapis.txt");
  62.             this.listBox1.Items.Clear();
  63.             foreach (string line in lines)
  64.             {
  65.                 this.listBox1.Items.Add(line);
  66.             }
  67.         }
  68.  
  69.         private void button2_Click(object sender, EventArgs e)
  70.         {
  71.            
  72.             listBox1.Items.Clear();
  73.            
  74.  
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement