DotNetBar第三方控件使用笔记 联系客服

发布时间 : 星期三 文章DotNetBar第三方控件使用笔记更新完毕开始阅读

控件MonthCalendarAdv的使用 下面两个图的区别,产生于属性“Dimension”。

控件MonthCalendarAdv的特殊使用

使用效果

正常情况,即没有特殊设置时

进行相应设置后

当然,这主要指的是周末的日期上的红叉“该功能和

控件的

事件相关,下面是实现上述功能的具体代码:

private void monthCalendarAdv2_PaintLabel(object sender, DayPaintEventArgs e) { // 叉掉星期天和禁用选择 DevComponents.Editors.DateTimeAdv.DayLabel day = sender as DevComponents.Editors.DateTimeAdv.DayLabel; if (day != null && day.Date > DateTime.MinValue && day.Date.DayOfWeek == DayOfWeek.Sunday) { day.Selectable = false; // 标记标签为不能选择 day.TrackMouse = false; // 不跟踪鼠标移动 e.PaintBackground(); e.PaintText(Color.Gray); Rectangle r = day.Bounds; r.Inflate(-2, -2);

System.Drawing.Drawing2D.SmoothingMode sm = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

using (Pen pen = new Pen(Color.FromArgb(128, Color.Red))) { e.Graphics.DrawLine(pen, r.X, r.Y, r.Right, r.Bottom); e.Graphics.DrawLine(pen, r.Right, r.Y, r.X, r.Bottom); } e.Graphics.SmoothingMode = sm; // 确保没有呈现在控件内部的部件 e.RenderParts = DevComponents.Editors.DateTimeAdv.eDayPaintParts.None; } }

private void monthCalendarAdv2_MonthChanged(object sender, EventArgs e) {

”,及不能被选择

// 你可以使用这个事件来添加定制的标记到calendar上,例如为某一天做预约 // 在本例中,我们只会选择从今天开始的8天 DateTime date = DateTime.Today.AddDays(8); // DayLabel控件是用来表示日历上的每个日期 DevComponents.Editors.DateTimeAdv.DayLabel day = monthCalendarAdv2.GetDay(date); if (day != null) // 如果日期没有显示在日历上则返回Null { // 在Label上显示日期 day.Image = global::EditorsDateNumericCalendar.Properties.Resources.Bell; day.ImageAlign = eLabelPartAlignment.MiddleRight; day.TextAlign = eLabelPartAlignment.MiddleLeft; day.Tooltip = \image to see appointments\; // 当某天的图像被点击时,你可以显示例如预约细节的弹出框 day.SubItems.Add(new ButtonItem(\, \AM Call Dave to setup meeting\)); day.SubItems.Add(new ButtonItem(\, \PM Lunch with Kurt\));

} }

控件DataTimeInput的使用

可产生如下图所示的效果

该图右上角的

的出现与否取决于下面几个属性

关于格式的控制 主要与属性“Format”有关,其有如下几个选项:short、long、shorttime、longtime与custom等。

注意:当使用“custom”自主控制格式时,要与属性“customFormat”配合使用。

在输入框中是否有复选框,与属性“ShowCheckBox”有关

输入框复选框是否处于“被选择(激活)”状态,与属性“LockUpdateChecked”有关

至于

,就相当于一个按钮(Buttom控件),可以添加一些特殊控制的代码。

控件DataTimeInput的

事件集是很重要的,其中

是个重要的事件。

示例程序:

private void dateTimeInput11_MonthCalendar_PaintLabel(object sender, DevComponents.Editors.DateTimeAdv.DayPaintEventArgs e) {

DevComponents.Editors.DateTimeAdv.DayLabel day = sender as DevComponents.Editors.DateTimeAdv.DayLabel;

if (day == null || day.Date == DateTime.MinValue)