//Loads up a new file for the user to cycle through or edit if so wish private void btnLoad_Click(object sender, EventArgs e) { //loads new file OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Open the text file you wish" ; //ofd.InitialDirectory = "c:\\"; ofd.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; //string infile2 = infile; //infile = infile2; if (ofd.ShowDialog() == DialogResult.OK) { Student[] pArray = new Student[10]; Read(ofd.FileName); DisplayRecord(0); lblmessage.Text = "New Data Loaded"; } }
//If The File Text box is focused and the user presses enter then the text within that box is used to load up an exsisting file private void txtfile_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string NewFileName = txtfile.Text; Student[] pArray = new Student[10]; Read(NewFileName); DisplayRecord(0); MessageBox.Show(NewFileName + " Was Loaded!!",NewFileName); infile = NewFileName; } }
public int SetStudetGrade( Student name ,int grade) { name.Grade = grade; return grade; }