5
Answers

Duplicate panels and controls created at runtime - Which button and textbox is it?

Tim Camper

Tim Camper

13y
13.6k
1
My application creates panels and controls, ie. labels, textboxes, etc., based on user input. The controls on the panel are located in the same place each time.

I need your help to figure out how in the program to know which textbox named "txtHandi" goes with what panel.
 
My code falls apart here:  void btnPlayerName_Click(object sender, EventArgs e)
It does not recognize the btnPlayerName I click on or the txtHandi.  I am sure it is something I am overlooking!

1. Please help me understand how I can associate each of the "btnPlayerName" to the panel it shows up on.
2. and how I can associate each of the txtHandi on that same panel so the line of code "int playerHandicap = Convert.ToInt32(txtHandi.Text);"
in the void btnPlayerName_Click(object sender, EventArgs e) will work.

I suspect I will need help with:
int playerGross = Convert.ToInt32(myGross[i].Text);
int holeHandicap = (handicapofhole[i]);

in "void btnPlayerName_Click(object sender, EventArgs e)" also.

If you can jump start me with a few of these items I most likely will be able to connect the dots.

I am providing portions of code for your review.

Thanks in advance for your help.



Answers (5)