silverlight中的Grid中添加Label控件
//cds.Width=newGridLength(110);//mygd.ColumnDefinitions.Add(cds);//为Grid添加列intlocatio...
//cds.Width = new GridLength(110);
//mygd.ColumnDefinitions.Add(cds);//为Grid添加列
int location = 0;
foreach (Dates indates in mydates)
{
RowDefinition rd = new RowDefinition();
gd_dates.RowDefinitions.Add(rd);//为Grid添加行
Label Time_Label = new Label() { Content = "" + indates.Date_l + "", Background = new SolidColorBrush(Colors.White),
HorizontalAlignment = HorizontalAlignment.Stretch ,HorizontalContentAlignment=HorizontalAlignment.Center};
gd_dates.Children.Add(Time_Label); //添加到Grid控件
Time_Label.SetValue(Grid.RowProperty, location); //设置按钮所在Grid控件的行
Time_Label = new Label() { Content= "" + indates.Date_r + "",Tag = "" + indates.Date_start + "",Name = location.ToString(),
Background = new SolidColorBrush(Colors.White),HorizontalAlignment = HorizontalAlignment.Stretch,HorizontalContentAlignment = HorizontalAlignment.Center};
Time_Label.MouseLeftButtonDown += new MouseButtonEventHandler(timedates_MouseLeftButtonDown);
gd_dates.Children.Add(Time_Label); //添加到Grid控件
Time_Label.SetValue(Grid.RowProperty, location); //设置按钮所在Grid控件的行
Time_Label.SetValue(Grid.ColumnProperty, 1); //设置按钮所在Grid控件的列
location++;
}
我这foreache循环向Grid中添加Lable控件,但是速度慢,请问知道速度快的方法? 展开
//mygd.ColumnDefinitions.Add(cds);//为Grid添加列
int location = 0;
foreach (Dates indates in mydates)
{
RowDefinition rd = new RowDefinition();
gd_dates.RowDefinitions.Add(rd);//为Grid添加行
Label Time_Label = new Label() { Content = "" + indates.Date_l + "", Background = new SolidColorBrush(Colors.White),
HorizontalAlignment = HorizontalAlignment.Stretch ,HorizontalContentAlignment=HorizontalAlignment.Center};
gd_dates.Children.Add(Time_Label); //添加到Grid控件
Time_Label.SetValue(Grid.RowProperty, location); //设置按钮所在Grid控件的行
Time_Label = new Label() { Content= "" + indates.Date_r + "",Tag = "" + indates.Date_start + "",Name = location.ToString(),
Background = new SolidColorBrush(Colors.White),HorizontalAlignment = HorizontalAlignment.Stretch,HorizontalContentAlignment = HorizontalAlignment.Center};
Time_Label.MouseLeftButtonDown += new MouseButtonEventHandler(timedates_MouseLeftButtonDown);
gd_dates.Children.Add(Time_Label); //添加到Grid控件
Time_Label.SetValue(Grid.RowProperty, location); //设置按钮所在Grid控件的行
Time_Label.SetValue(Grid.ColumnProperty, 1); //设置按钮所在Grid控件的列
location++;
}
我这foreache循环向Grid中添加Lable控件,但是速度慢,请问知道速度快的方法? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询