Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.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.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }
  18.  
  19.         private void button2_Click(object sender, EventArgs e)
  20.         {
  21.            
  22.             for (int i = 5; i >= 0; i--)
  23.             {
  24.                 if ((listBox1.Items[i].ToString() == "a") || (listBox1.Items[i].ToString() == "e"))
  25.                 {
  26.                     listBox1.Items.Remove(listBox1.Items[i]);
  27.                 }
  28.             }
  29.         }
  30.  
  31.         private void button1_Click(object sender, EventArgs e)
  32.         {
  33.             listBox1.Items.Clear();
  34.             listBox1.Items.Add("a");
  35.             listBox1.Items.Add("b");
  36.             listBox1.Items.Add("c");
  37.             listBox1.Items.Add("d");
  38.             listBox1.Items.Add("e");
  39.             listBox1.Items.Add("f");
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement