Program/C#

차일드 컨트롤들의 열거...

TJStory 2008. 2. 29. 14:27
< 환경 : WPF 프로젝, VS2008 >

WPF 윈도우 내의 그리드에 네임을 붙혀주고.. 해당 그리드의 칠드런에 접근하면 된다..
아래는 다수의 콤보박스의 크기를 일정하게 해주는 작업이고...
콤보박스의 이름이 "cbPost" 인 것은 제외 시킨다.

foreach (UIElement Combo in this.PageSettingGrid.Children )
            {
                if (Combo is ComboBox)
                {
                    if ((Combo as ComboBox).Name != "cbPost")
                    {
                        (Combo as ComboBox).SelectedIndex = 0;
                       
                        (Combo as ComboBox).Width = 40;
                        (Combo as ComboBox).Height = 20;
                    }
                }
            }