Advertisement
Guest User

Untitled

a guest
May 26th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 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.  
  11. namespace Popis
  12. {
  13. public partial class Form1 : Form
  14. {
  15. List<string> popis = new List<string>();
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void Form1_Load(object sender, EventArgs e)
  22. {
  23. button2.Enabled = false;
  24. }
  25.  
  26. private void button2_Click(object sender, EventArgs e)
  27. {
  28. popis.RemoveAt(listBox1.SelectedIndex);
  29. listBox1.Items.Clear();
  30. foreach (string i in popis)
  31. {
  32. listBox1.Items.Add(i);
  33. }
  34.  
  35. if (listBox1.Items.Count == 0)
  36. {
  37. button2.Enabled = false;
  38. }
  39. }
  40.  
  41. private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
  42. {
  43.  
  44. }
  45.  
  46. private void button1_Click(object sender, EventArgs e)
  47. {
  48. bool empty = false;
  49. if (textBox1.Text == "")
  50. {
  51. MessageBox.Show("Niste unijeli artikl.", "Pogreška!");
  52. empty = true;
  53. }
  54. else
  55. empty = false;
  56.  
  57. if (!empty)
  58. {
  59. popis.Add(textBox1.Text);
  60. listBox1.Items.Add(textBox1.Text);
  61. button2.Enabled = true;
  62. textBox1.Text = "";
  63. }
  64.  
  65. }
  66.  
  67. private void button3_Click(object sender, EventArgs e)
  68. {
  69. popis.Sort();
  70. listBox1.Items.Clear();
  71. foreach (string i in popis)
  72. {
  73. listBox1.Items.Add(i);
  74. }
  75. }
  76.  
  77. private void button4_Click(object sender, EventArgs e)
  78. {
  79. Application.Exit();
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement