public void SetGridClanderValue() { //grid_clanderPanel.Controls.Clear(); List <DateTime> dtList = GetTimeList(); int i = 0; for (int r = 0; r < 6; r++) { for (int c = 0; c < 7; c++) { //ButtonControl b = new ButtonControl(); ButtonControl b = grid_clanderPanel.GetControlFromPosition(c, r) as ButtonControl; b.Text = dtList[i].Day.ToString();// +"\r\n" + "666"; //b.Tag = dtList[i].Day; b.Font = new Font("黑体", 13f); b.Dock = DockStyle.Fill; b.Margin = new System.Windows.Forms.Padding(0); b.Padding = new System.Windows.Forms.Padding(0); if (c == 0 || c == 6) { b.Style = ButtonStyle.Calendar_weekend; b.Tag = "weekend"; } else { b.Style = ButtonStyle.Calendar_day; b.Tag = "weekday"; } //b.MouseDown += new System.Windows.Forms.MouseEventHandler(this._MouseDown); /*Grid.SetRow(b, r); * Grid.SetColumn(b, c); */ //grid_clanderPanel.Controls.Add(b,c,r); if (dtList[i].Month != currentYearMonth.Month || dtList[i] < System.DateTime.Now.Date) { b.Enabled = false; } else//当月 { if (ValidDateLists.Count != 0 && ValidDateLists.Count > monthIndex) { if (!ValidDateLists[monthIndex].ContainsKey(dtList[i].Day)) { b.Enabled = false; } else { b.Enabled = true; } } else { b.Enabled = false; } } if (dtList[i].Year == System.DateTime.Now.Year && dtList[i].Month == System.DateTime.Now.Month && dtList[i].Day == System.DateTime.Now.Day) { b.Style = ButtonStyle.Calendar_today; } //b.Click += new RoutedEventHandler(OK); i++; } } }
public void SetGridClanderValue() { //grid_clanderPanel.Controls.Clear(); List <DateTime> dtList = GetTimeList(); int i = 0; for (int r = 0; r < 6; r++) { for (int c = 0; c < 7; c++) { //ButtonControl b = new ButtonControl(); ButtonControl b = grid_clanderPanel.GetControlFromPosition(c, r) as ButtonControl; b.Text = dtList[i].Day.ToString();// +"\r\n" + "666"; //b.Tag = dtList[i].Day; b.Font = new Font("黑体", 12f); b.Dock = DockStyle.Fill; b.Margin = new System.Windows.Forms.Padding(0); b.Padding = new System.Windows.Forms.Padding(0); if (c == 0 || c == 6) { b.Style = ButtonStyle.Calendar_weekend; b.Tag = "weekend_" + dtList[i].Month; } else { b.Style = ButtonStyle.Calendar_day; b.Tag = "weekday_" + dtList[i].Month; } //b.MouseDown += new System.Windows.Forms.MouseEventHandler(this._MouseDown); /*Grid.SetRow(b, r); * Grid.SetColumn(b, c); */ //grid_clanderPanel.Controls.Add(b,c,r); //if (dtList[i].Month != currentYearMonth.Month || dtList[i] < System.DateTime.Now.Date)//撤销当月限制 if (dtList[i] < System.DateTime.Now.Date)//已过日期限制 { b.SecondText = String.Empty; b.Enabled = false; } else { if (ValidDateLists.Count != 0 && ValidDateLists.Count > monthIndex) { for (int monindex = 0; monindex < ValidDateLists.Count; monindex++) { if (ValidDateLists[monindex].ContainsKey(dtList[i].Day) && Int32.Parse(b.Tag.ToString().Split('_')[1]) == System.DateTime.Now.AddMonths(monindex).Month)//不在当月的日期若在界面里也允许查看和点击 { if (ValidDateLists[monindex][Int32.Parse(b.Text)] == "约满") { b.SecondText = "约满"; } b.Enabled = true; break; } else { b.SecondText = String.Empty; b.Enabled = false; } } } else { b.SecondText = String.Empty; b.Enabled = false; } } if (dtList[i].Year == System.DateTime.Now.Year && dtList[i].Month == System.DateTime.Now.Month && dtList[i].Day == System.DateTime.Now.Day) { b.Style = ButtonStyle.Calendar_today; } //b.Click += new RoutedEventHandler(OK); i++; } } }