3
Answers

Windows Forms Creating TextBoxes & Labels Dynamically

richard smith

richard smith

10y
1.3k
1
I have been manually doing this process for quite some time and think that their must be a better way to do such.  So here is the back-story.  There is a SQL Table that holds 3 fields, QuestionToAsk, Responses, ID - of course pretty self explanatory here, the QuestionToAsk of course would be the label and a question, the Responses would be textboxes and would house any entered response, and the ID is just an ID field.  Some sample data from the table would be like so ----
QuestionToAsk ---- Responses ---- ID
Top 5 Movies?         Movie1            1
                                   Movie2            2
                                   Movie3            3
                                   Movie4            4
                                   Movie5            5
Fav from top 5?       Top5Fav          6
Fav Hobby?              FavHobby        7
Top 4 Cars?              Car1                  8
                                   Car2                  9
                                   Car3                  10
                                   Car4                  11 
 
I have been just manually creating each label and copy/paste the text, and creating the textboxes to be associated with them because I can not find a way to associate the multiple response textboxes with the QuestionToAsk.  Meaning, How can I query to see that Top 5 Movies needs 5 textboxes, and Fav from top5 only needs 1, so that I can dynamically create all of the information?
Answers (3)