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 WindowsFormsApplication2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- int ILE;
- Random r = new Random();
- lista1.Items.Clear();
- ILE = r.Next(5, 20);
- for (int i = 0; i < ILE; i++)
- {
- lista1.Items.Add(r.Next(100));
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- int min = Convert.ToInt32((lista1.Items[0]));
- int lenght = lista1.Items.Count;
- for (int i = 0; i < lenght; i++)
- {
- int value = Convert.ToInt32(lista1.Items[i]);
- if (value < min)
- {
- min = value;
- }
- }
- lista1.SelectedItem = min;
- }
- private void button3_Click(object sender, EventArgs e)
- {
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
- {
- string linia;
- lista1.Items.Clear();
- FileInfo plik = new FileInfo(openFileDialog1.FileName);
- StreamReader p = plik.OpenText();
- while((linia = p.ReadLine()) != null){
- lista1.Items.Add(linia);
- }
- }
- }
- private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement