Question

I have a grid with labels and text boxes.
I want to get the content of the label.
Very easy if you know it is a label.
But this is what I have:

foreach (var t in Grid1.Children)
    {
         if (t.GetType() == typeof(Label))
         {
                string val = t.????;
         }
    }  

How do I get the content of this label?

Was it helpful?

Solution

    foreach (var t in Grid1.Children)
    {
         if (t is Label)
         {
                string val = ((Label)t).Content.ToString()
         }
    }  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top