First Form (maint_form):
private void updateBtn_Click(object sender, EventArgs e)
{
int index = studentList.SelectedIndex; // index of listbox same as Students...
student updateStudent = Students[index]; // retrieve student to udpate
scoreupdate scoreupdateFrm = new scoreupdate(updateStudent); // pass student to update form
scoreupdateFrm.ShowDialog(); // show the form...
}
scoreupdate form:
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 maint_student_scores
{
public partial class scoreupdate : Form
{
public student testscores = new student();
List<student> Students;
public scoreupdate(student updateStudent)
{
InitializeComponent();
}
private void updatescores_Load(object sender, EventArgs e)
{
}
private void cancelBtn_Click(object sender, EventArgs e)
{
//Close this box!
this.Close();
}
private void clearscoresBtn_Click(object sender, EventArgs e)
{
//Lets clear all scores listed in our box!
testscores.Scores.Clear();
}
private void okBtn_Click(object sender, EventArgs e)
{
//lets add the name to our list!
testscores.name = nameTbox.Text;
//make sure they get their scores also!
Students.Add(testscores);
//And we'll close this box so its out of the way and saved to our list.
this.Close();
}
private void addBtn_Click(object sender, EventArgs e)
{
updatescores_add updateScoresAddFrm = new updatescores_add();
updateScoresAddFrm.ShowDialog();
}
private void updateBtn_Click(object sender, EventArgs e)
{
updatescores_update updateScoresUpdateFrm = new updatescores_update();
updateScoresUpdateFrm.ShowDialog();
}
private void removeBtn_Click(object sender, EventArgs e)
{
testscores.deleteScore();
}
private void studentnameTbox_TextChanged(object sender, EventArgs e)
{
Students.ToString();
}
}
}
I guess my naming convention a bit weird, but its kinda how I understand it from my eye, I will work on changing a bit of it. Personally I just want to be rid of this project because I get ultra stressed when it comes to the weekend.