Advertisement
Leo1502

Forms_01

Feb 3rd, 2023 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.36 KB | Source Code | 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.Threading;
  11. using System.IO;
  12.  
  13. namespace FormsApp_01
  14. {
  15.     public partial class Student : Form
  16.     {
  17.         public Student()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.  
  22.         private void btnOK_Click(object sender, EventArgs e)
  23.         {
  24.             string path = "D:\\Skola\\NOP\\Forms\\Ucenik.txt";
  25.  
  26.             if (!string.IsNullOrEmpty(textBox1.Text) && !string.IsNullOrEmpty(textBox2.Text) && !string.IsNullOrEmpty(comboBox1.Text))
  27.             {
  28.                 using (StreamWriter sw = new StreamWriter(path))
  29.                 {
  30.                     sw.WriteLine(textBox1.Text);
  31.                     sw.WriteLine(textBox2.Text);
  32.                     sw.WriteLine(comboBox1.Text);
  33.  
  34.                     textBox1.Clear();
  35.                     textBox2.Clear();
  36.                     comboBox1.ResetText();
  37.                 }
  38.             }
  39.  
  40.             else
  41.             {
  42.                 MessageBox.Show("Greška, popunite polja!");
  43.             }
  44.         }
  45.  
  46.         private void Student_Load(object sender, EventArgs e)
  47.         {
  48.             txtDateTime.Text = DateTime.Now.ToString();
  49.         }
  50.     }
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement