1

I have a grid. Inside the grid cells, there are borders. Borders contain textboxes which have text.

How to change the text in the textbox at row m and column n? I can find the border but can't access the child textblock of border using below code.

 for (int i=0; i< MyGrid.Children.Count; i++)
    {
    UIElement child = MyGrid.Children[i]; 


     if ((Grid.GetRow(child) == m) && (Grid.GetColumn(child) == n))

                {

                     child.GetValue();
                }
     }

I want to find the text of child textblock of child (grid's child which is a border control)

user2330678
  • 2,221
  • 14
  • 43
  • 67
  • Please read [this answer](http://stackoverflow.com/a/15344546/643085) to understand the proper way to do what you need in WPF. You don't "change the text in the textbox" in WPF because [UI is NOT data](http://stackoverflow.com/a/14382137/643085) – Federico Berasategui Apr 09 '14 at 22:20

1 Answers1

0

did you try to cast child into Border and to get it's own child?

for (int i=0; i< MyGrid.Children.Count; i++)
{
UIElement child = MyGrid.Children[i /*by the way it should be i?*/]; 


 if ((Grid.GetRow(child) == m) && (Grid.GetColumn(child) == n))

            {

                 ((child as Border).Child as TextBox).Text = "some text";
            }
 }
Dmitry
  • 2,033
  • 1
  • 22
  • 31