#region [DateTimePicker控件加入ToolStripControl] /// <summary> /// 添加DateTimePicker方法 /// </summary> /// <param name="n">传入需要添加的位置参数</param> private void AddDtPtoToolstrip(int n) { DateTimePicker dtp = new DateTimePicker { Width = 110, Format = DateTimePickerFormat.Custom, CustomFormat = " " //插入一个空格,防止一加载就带入当前时间 }; ToolStripControlHost host1 = new ToolStripControlHost(dtp); toolStrip1.Items.Insert(n, host1); dtp.ValueChanged += (sender, args) => dtp.CustomFormat = "yyyy-MM-dd"; //当点击日期时,插入自定义考试日期时间 } #endregion