Program funkční. Psaný na rychlo. Nejsou tam žádné kontroly vstupních dat, ošetřené vyjímky apod.! Bylo by vhodné doplnit.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HomeWork
{
public partial class Form1 : Form
{
public List<String> families = new String[14].ToList();
public Form1()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
families.RemoveAt(Convert.ToInt16(txtFlat.Text));
families.Insert(Convert.ToInt16(txtFlat.Text),txtFamily.Text);
txtFamily.Text = "";
}
private void btnRemove_Click(object sender, EventArgs e)
{
families.RemoveAt(Convert.ToInt16(txtFlat.Text));
families.Insert(Convert.ToInt16(txtFlat.Text), "");
}
private void btnList_Click(object sender, EventArgs e)
{
lblList.Text = families.ElementAt(Convert.ToInt16(txtFlat.Text));
}
private void btnListAll_Click(object sender, EventArgs e)
{
lblList.Text = "";
for (int i = 1; i <= 13; i++)
{
lblList.Text += i + " " + families.ElementAt(i) + Environment.NewLine;
}
}
}
}