private void FrmMain_Load(object sender, EventArgs e) { var sr = new StreamReader(@"..\..\Resources\pontszamok.txt", Encoding.UTF8); while (!sr.EndOfStream) { var sor = sr.ReadLine().Split(';'); var diak = new Diak() { Nev = sor[0], Pontszam = int.Parse(sor[1]), }; //RAM Program.diakok.Add(diak); //GUI AddRtbRow(diak); } sr.Close(); }
private void BtnAdatbevitel_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(tbNev.Text) && int.TryParse(tbPontszam.Text, out _)) { var diak = new Diak() { Nev = tbNev.Text, Pontszam = int.Parse(tbPontszam.Text) }; //RAM Program.diakok.Add(diak); //GUI AddRtbRow(diak); } else { MessageBox.Show( caption: "HIBA", text: "valami nem stimmel", icon: MessageBoxIcon.Error, buttons: MessageBoxButtons.OK); } }
private void AddRtbRow(Diak d) { rtbDiakok.Text += string.Format("{0, -22} {1, 3}\n", d.Nev, d.Pontszam); }