Geo GeometricDatabase = new Geo();
string line;
Microsoft.Win32.OpenFileDialog fileDlg = new Microsoft.Win32.OpenFileDialog();
fileDlg.ShowDialog();
MessageBox.Show(fileDlg.FileName);
System.IO.StreamReader TextReader;
TextReader = new System.IO.StreamReader(fileDlg.FileName);
while ((line = TextReader.ReadLine()) != null)
{
string[] words = line.Split(',');
GeometricDatabase.AddColor(words[0]);
GeometricDatabase.AddShape(words[1]);
GeometricDatabase.AddSize(words[2]);
}
So basically, its opening a text file (which I have formated in a certain way) it reads each line separately taking the words and putting them into an array, then takes the words from the generic array and adds them to the specific list. Now the trouble comes when in the same window but different button I want to count the number of elements in say Color. If I add just:
GeoListBox.Text = GeometricDatabase.GetCount().ToString();
I recieve the error "The name 'GeometricDatabase' does not exist in the current context", which is what I would expect. Adding the same thing as the above button:
Geo GeometricDatabase = new Geo(); GeoListBox.Text = GeometricDatabase.GetCount().ToString();
Gives me a count of zero, so I am assuming there is a way to carry over the GeometricDatabase without creating a new one?
My next question is, what is the best way to post these list's in a large textbox in a organized fashion. I could do:
GeoListBox.Text = GeometricDatabase.getshape(1) + "\n" + GeometricDatabase.getcolor(1);
I would have to do this for every single element and list which would get very tedious and long. Any suggestions? The goal is to make it look something similar to this (having the codebox represent the textbox in the program)
Square Green 24 Rectangle Red 58 Triangle Blue 36
Also note: I have tried using the count to find the number of elements then make a for loop to just print it, but unfortunately I will just keep erasing the previous index's data and replace it with the next. I know these are relatively long and probably pretty silly, but just overlooking them at the moment. Thanks in advance!

New Topic/Question
Reply




MultiQuote




|