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?

Était-ce utile?

La solution

    foreach (var t in Grid1.Children)
    {
         if (t is Label)
         {
                string val = ((Label)t).Content.ToString()
         }
    }  
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top