简体   繁体   English

更改文本框中文本的位置,在网格的第m行和第列的边框内

[英]Change the text in the textbox, inside border at row m and column of a grid

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? 如何更改文本框中第m行和第n列的文本? I can find the border but can't access the child textblock of border using below code. 我可以找到边框,但是无法使用以下代码访问border的子文本块。

 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) 我想找到child的child textblock的文本(grid的child是边界控件)

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";
            }
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM