代码改变世界

Silverlight Visifire控件 .net后台控制aspx页面控件的显示与隐藏,动态给控件赋值,选定默认值的设定

2014-03-11 10:57  悠悠鑫宝  阅读(376)  评论(0编辑  收藏  举报

.net后台代码:

控件的显示与隐藏:

 this.dateStart.Visibility = Visibility.Collapsed;//不显示控件
 this.dateYear.Visibility = Visibility.Visible;//显示控件

设置控件位置:

this.oildomName.Margin = new Thickness(167, 12, 0, 0);
this.oildomNameList.Margin = new Thickness(212, 12, 0, 0);
this.btnQuery.Margin = new Thickness(322, 12, 0, 0);
this.btnBack.Margin = new Thickness(407, 12, 0, 0);

 控件赋值,选定值的设定:

 for (int ii = DateTime.Today.Year; ii >= 1980; ii--)
 {
                    string item = string.Format("{0}年", ii.ToString());
                    // this.dateYear.Items.Add(item);
                    if (item != sClickReportDate)
                    {
                        this.dateYear.Items.Add(item);
                    }
                    else
                    {
                        ComboBoxItem cbi1 = new ComboBoxItem();
                        cbi1.SetValue(ComboBoxItem.ContentProperty, sClickReportDate);
                        this.dateYear.Items.Add(cbi1);
                        //下拉框赋选定值
                        this.dateYear.SelectedItem = cbi1;
                    }
}