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

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

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。