G Scott
asked on
WPF Dynamic Class Values
So I have some dynamically created TextBox controls in a window. After the has filled in all the boxes they click a button. I want to pass those values to a class that I wrote to store the answers until they are all done. I get the values by doing this:
Here is my class:
How can I access the classes dynamically using a For Loop?
Basically assigning value from "((LogicalTreeHelper.FindL ogicalNode (gridQuest ion, "commentSep" + i) as TextBox).Text);" to answersClass.answerSep + i
Thanks for any help on this.
MessageBox.Show((LogicalTreeHelper.FindLogicalNode(gridQuestion, "commentSep" + i) as TextBox).Text);
Here is my class:
class answersClass
//Separate Answers Section ************************************
public static string answerSep1
{
get { return ansSep1; }
set { ansSep1 = value; }
}
private static string ansSep1;
public static string answerSep2
{
get { return ansSep2; }
set { ansSep2 = value; }
}
private static string ansSep2;
public static string answerSep3
{
get { return ansSep3; }
set { ansSep3 = value; }
}
private static string ansSep3;
public static string answerSep4
{
get { return ansSep4; }
set { ansSep4 = value; }
}
private static string ansSep4;
public static string answerSep5
{
get { return ansSep5; }
set { ansSep5 = value; }
}
private static string ansSep5;
}
}
How can I access the classes dynamically using a For Loop?
Basically assigning value from "((LogicalTreeHelper.FindL
Thanks for any help on this.
ASKER
Hey TheLearnedOne,
I only have one valid reason and that is because I don't know what I am doing. Lol. I am trying to advance from VB to C#, but apparently I was doing it wrong in VB, too. Haha. So, once I have it as a list how do I loop through those values to insert them into SQL (which is what I end up doing)? Is that List<string> indexed? AnswerList(0), AnswerList(1) etc??
I only have one valid reason and that is because I don't know what I am doing. Lol. I am trying to advance from VB to C#, but apparently I was doing it wrong in VB, too. Haha. So, once I have it as a list how do I loop through those values to insert them into SQL (which is what I end up doing)? Is that List<string> indexed? AnswerList(0), AnswerList(1) etc??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I can make this work. Thanks so much for the <List> tip. That is a great way to do it, and I think I can apply that to a bunch of other projects I have done.
Open in new window