BOOnZ
BOOnZ

Reputation: 848

retrieve label text from tablelayoutpanel

i have just begun experimenting on using table layout panel to keep things organised. I have added a label control with some text into a cell. how do I get this text back into a string variable at a later time? or even modify the text in the label in the cell?

Upvotes: 0

Views: 1480

Answers (1)

competent_tech
competent_tech

Reputation: 44931

When you add the control, just store a reference to it in the form.

Add this to the main form body (not inside a method):

Label myLabel;

in your code that adds the label:

myLabel = new Label();
myLabel.Text = "Some Text";
// Pseudo-code
myPanel.Cells.Add(myLabel);

Then later, just access myLabel anywhere in the form code.

Upvotes: 1

Related Questions