I know that this is possible to be done with application settings, but I want to do it this way:
I have some textboxes and other controls that have Text property. I am doing a loop and save the Name and Text property of them in a text file. The saving statement is like:
if (ctrl != null) sb.AppendLine(ctrl.Name.ToString() + ":" + ctrl.Text);
When I want to load them back I want to do it this way, but since I can not point to the Name of the controls, I am stuck! (I beleive it was possible in PHP to point to a variable using other variables!)
using (StreamReader file = new StreamReader(ofile.FileName))
{
while((line = file.ReadLine()) != null)
{
if (line.StartsWith("#")) continue; //Line is a commment so skip
else
{
data = line.Split(':');
//How to set back the text property to the variable?
}
}
}
What I have in mind now, is to save Tag property of controls instead of theire Name property. But the problem is my controls are all scaterred in side nested panels and stuff like that so I have to do a lot of LOOPING! to compare theire tags with tags avilable in my saved file (note that I am not going to save all controls in the text file, just some of em!)
What to do ?
You can find control by it’s name if you have access to form’s Controls property