Need help with this GUI
I keep getting error when I try to remove students , etc.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jan 19, 2012, 11:44 AM EST
I've done the best I can with it but notice that if you try to expand the membership to more than 10 the program will error out because of an error in the RetreiveStudents() method.
Another problem is that there's only 5 students in the initial database but the aforementioned method returns an array of 10 student objects, the last 5 being null. The nulls need to be removed to avoid various problems arising:
Prime bRank #2,035 · 712 reputationPosted Jan 19, 2012, 11:09 AM EST
Prime bRank #2,035 · 712 reputationPosted Jan 19, 2012, 11:53 AM EST
I'll have to go through all of them and rename it, also I have to rename all the objects in the form it self, since they are default names if i wont change it then my teacher will give me bad grade(maybe C). And this is my last semester in this college so I need to get all A's in all four classes that I am currently taking otherwise I wont be accepted to a four college due to my GPA being below the limit....
I had fun during few semesters in community college and it killed my GPA so now I am trying to fix all the mistakes I did..... Also the reason I am telling you all this is so you wont think I am stupid or something.. I am good student , just met wrong people at college and it cost me a lot.
VulpesRank #55 · 29.2K reputationPosted Jan 19, 2012, 12:11 PM EST
public Student[] RetreiveStudents()
{
Student[] list = new Student[10];
students.Clear(); // clear list
FileStream inFile = new FileStream(FILE_NAME, FileMode.Open, FileAccess.Read);
BinaryFormatter binFormatter = new BinaryFormatter();
int index = 0;
while (inFile.Position < inFile.Length)
{
if (index >= list.Length)
{
list = Expand(list); // need to assign result back to list
}
list[index++] = (Student)binFormatter.Deserialize(inFile);
students.Add(list[index - 1]);
}
inFile.Close();
return list;
}
It's a bit rich asking you to begin method names with a lower case letter when they all begin with capital letters in the PersistantData class. That's the recommended practice for .NET anyway - how many methods have you seen in the framework that begin with lower case letters?. What they're asking you to do is the Java naming standard.
Prime bRank #2,035 · 712 reputationPosted Jan 19, 2012, 12:44 PM EST
Prime bRank #2,035 · 712 reputationPosted Jan 21, 2012, 7:16 AM EST
For example( you have to have GUI running) if you click View Students tab you will see First Name label, the textbox next to it named textbox1, well I renamed that textbox1 to viewStudFName. viewStud stands for the tab name and FName is first name, is it good ? or should i rename to to something different?
Prime bRank #2,035 · 712 reputationPosted Jan 21, 2012, 8:05 AM EST
VulpesRank #55 · 29.2K reputationPosted Jan 21, 2012, 1:54 PM EST
Prime bRank #2,035 · 712 reputationPosted Jan 21, 2012, 2:13 PM EST
Prime bRank #2,035 · 712 reputationPosted Jan 21, 2012, 3:56 PM EST
I re-uploaded the file so its easier for you to see , i changed all the names
http://www.4shared.com/rar/dUztIHti/Student_Viewer.html
Once you open it , you will the error.
VulpesRank #55 · 29.2K reputationPosted Jan 22, 2012, 1:04 AM EST
It will then build OK but won't run properly as some code in form1.cs hasn't yet been updated in line with my previous post - button2_Click for instance.
So, I'd go through each method in turn, in the light of the changed names, to make sure you've picked up all the changes as it's quite intricate.
Incidentally, the lines I originally had - checking that there were actually some students remaining in the database before doing anything - are no longer needed as all the navigation buttons will be disabled in this event.
Prime bRank #2,035 · 712 reputationPosted Jan 22, 2012, 7:26 AM EST
Thank you Vulpes, for all that trouble you had to go through.
Prime bRank #2,035 · 712 reputationPosted Jan 22, 2012, 7:45 AM EST
VulpesRank #55 · 29.2K reputationPosted Jan 22, 2012, 8:30 AM EST
The easiest way to do this is to right click on the name of the eventhandler in the code window, select Refactor -> Rename, enter the new name of the handler in the textbox and OK it. This should change it everywhere it's used including the InitializeComponent method.
Prime bRank #2,035 · 712 reputationPosted Jan 22, 2012, 8:54 AM EST