private void buttonEdit_Click(object sender, EventArgs e) { int i = gridStud.CurrentCell.RowIndex; int adr = (int)gridStud[0, i].Value; stud.Read(aFile, adr, true); if (Program.formEditStud.ShowDialog() == DialogResult.OK) { stud.Write(aFile, adr); SetGrid(); } }
private void SetGrid() { aFile = new FileStream("Stud.dat", FileMode.Open); aFile.Seek(0, SeekOrigin.Begin); int adr = 0; int L = (int)aFile.Length / stud.size; int L2 = 0; gridStud.RowCount = 0; for (int i = 0; i <= L - 1; i++) { stud.Read(aFile, adr++, false); string s = FormGroup.findStr; if ((stud.isExists != 0) && ((stud.fio.S.IndexOf(s) == 0) || (s.Length == 0))) { gridStud.RowCount = ++L2; gridStud[0, L2 - 1].Value = i; gridStud[1, L2 - 1].Value = stud.idGroup; gridStud[2, L2 - 1].Value = stud.idStud; gridStud[3, L2 - 1].Value = stud.fio.S; } } aFile.Close(); aFile.Dispose(); }