2017-11-25 6 views
0

의 내가 있다고 가정 해 봅시다 :액세스 그리드 요소 프로그래밍

<Grid Name="paramGrid"> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition/> 
    </Grid.ColumnDefinitions> 

    <Grid.RowDefinitions> 
     <RowDefinition/> 
     <RowDefinition/> 
    </Grid.RowDefinitions> 

    <TextBox Grid.Row="0" Grid.Column="0"/> 
    <TextBox Grid.Row="1" Grid.Column="0"/> 
</Grid> 

I 같은 행/열을 추가하는 방법을 알고 :

paramGrid.RowDefinitions.Add(new RowDefinition()); 

TextBox tb = new TextBox(); 
tb.Text = "Sample"; 
tb.Name = "textBox"; 

paramGrid.Children.Add(tb); 
Grid.SetColumn(tb, 0); 
Grid.SetRow(tb, 2); 

위는 새 행에 텍스트 상자를 추가합니다.

제 질문은 : 지금 어떻게 접근할까요? 새로운 행의 TextBox이라는 .Text 속성을 쿼리해야합니다.

답변

2

텍스트 상자에 심판 유지 :

private TextBox m_Tb; 

... 

m_Tb = new TextBox(); 
m_Tb.Text = "Sample"; 
m_Tb.Name = "textBox"; 

.... 

something something = m_Tb.Text; 

그리드의 Children 모음에서 찾기 : 텍스트 상자 격자의 유일한 아이 중 하나 인 경우

분명히 [0]
var tb = (TextBox)paramGrid.Children[0]; 
something something = tb.Text; 

에만 작동합니다 또는 첫번째 것.