GcCalendarEditingControl.DrawModeプロパティを使用してカレンダーを描画する方法を設定できます。デフォルトでは、Normalです。
DrawModeの値 |
説明 |
Normal |
GcCalendarCellの日付および月領域はシステムによって描画されます。 |
OwnerDrawDay |
CalendarTypeがMonthDayの場合、GcCalendarEditingControlのDrawDayイベントを使用して日付領域を描画できます。 |
OwnerDrawMonth |
CalendarTypeがYearMonthの場合、GcCalendarEditingControlのDrawMonthイベントを使用して日付領域を描画できます。 |
OwnerDrawDayAndMonth |
GcCalendarEditingControlのDrawDayイベントおよびDrawMonthイベントを使用して日付および月領域を描画できます。 |
GcCalendarEditingControl.DrawModeプロパティがOwnerDrawDayまたはOwnerDrawDayAndMonthの場合、日付領域が変わるときにGcCalendarEditingControlのDrawDayイベントが発生します。イベントハンドラのパラメーターとして渡されたDrawDayEventArgsクラスのプロパティとメソッドを使用して日付部分を描画できます。GcCalendarEditingControl.DrawModeプロパティがOwnerDrawMonthまたはOwnerDrawDayAndMonthの場合、月領域が変わるときにGcCalendarEditingControlのDrawMonthイベントが発生します。DrawMonthEventArgsクラスのプロパティとメソッドを使用して月部分を描画します。
次のサンプルコードは、GcCalendarEditingControlのDrawDayイベントを使用して、特定の日付領域に任意のテキストと画像を使用して描画する方法を示します。
 |
- 以下のサンプルコードでは、GcCalendarCellの編集用コントロールを使用するため、セルにフォーカスがある場合のみ任意のテキストと画像を表示します。
|
Imports GrapeCity.Win.MultiRow
Imports PlusPakCell = GrapeCity.Win.MultiRow.PlusPak
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim GcCalendarCell1 = New PlusPakCell.GcCalendarCell()
GcCalendarCell1.Lines.Vertical = New PlusPakCell.Line(GrapeCity.Win.Calendar.LineStyle.Hair, Color.Gray)
GcCalendarCell1.Lines.Horizontal = New PlusPakCell.Line(GrapeCity.Win.Calendar.LineStyle.Single, Color.Gray)
GcCalendarCell1.Size = New Size(270, 270)
GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() {GcCalendarCell1})
GcMultiRow1.RowCount = 10
End Sub
Private Sub GcMultiRow1_EditingControlShowing(ByVal sender As Object, ByVal e As GrapeCity.Win.MultiRow.EditingControlShowingEventArgs) Handles GcMultiRow1.EditingControlShowing
Dim gcCalendarEditor As PlusPakCell.GcCalendarEditingControl = TryCast(e.Control, PlusPakCell.GcCalendarEditingControl)
If gcCalendarEditor IsNot Nothing Then
gcCalendarEditor.DrawMode = GrapeCity.Win.Calendar.CalendarDrawMode.OwnerDrawDay
' イベントを設定します。
RemoveHandler gcCalendarEditor.DrawDay, AddressOf Me.Editor_DrawDay
AddHandler gcCalendarEditor.DrawDay, AddressOf Me.Editor_DrawDay
End If
End Sub
Private Sub Editor_DrawDay(sender As Object, e As GrapeCity.Win.Calendar.DrawDayEventArgs)
If e.Month = 6 And e.Day = 4 Then
Dim myBrush As Brush = Brushes.Red
e.DrawBackground()
Dim format As New StringFormat()
format.Alignment = StringAlignment.Far
format.LineAlignment = StringAlignment.Center
e.Graphics.DrawString("休", New Font("MS ゴシック", 9), myBrush, e.Bounds, format)
e.Graphics.DrawImage(New Bitmap("c:\icon.png"), New Point(e.Bounds.X, e.Bounds.Y))
Else
e.DrawBackground()
e.DrawTodayImageAndFocusRectangle()
e.DrawForeground()
End If
End Sub
using GrapeCity.Win.MultiRow;
using PlusPakCell = GrapeCity.Win.MultiRow.PlusPak;
private void Form1_Load(object sender, EventArgs e)
{
PlusPakCell.GcCalendarCell gcCalendarCell1 = new PlusPakCell.GcCalendarCell();
gcCalendarCell1.Lines.Vertical = new PlusPakCell.Line(GrapeCity.Win.Calendar.LineStyle.Hair, Color.Gray);
gcCalendarCell1.Lines.Horizontal = new PlusPakCell.Line(GrapeCity.Win.Calendar.LineStyle.Single, Color.Gray);
gcCalendarCell1.Size = new Size(270, 270);
gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { gcCalendarCell1 });
gcMultiRow1.RowCount = 10;
}
private void gcMultiRow1_EditingControlShowing(object sender, EditingControlShowingEventArgs e)
{
PlusPakCell.GcCalendarEditingControl gcCalendarEditor = (e.Control as PlusPakCell.GcCalendarEditingControl);
if (gcCalendarEditor != null)
{
gcCalendarEditor.DrawMode = GrapeCity.Win.Calendar.CalendarDrawMode.OwnerDrawDay;
// イベントを設定します。
gcCalendarEditor.DrawDay -= Editor_DrawDay;
gcCalendarEditor.DrawDay += Editor_DrawDay;
}
}
private void Editor_DrawDay(object sender, GrapeCity.Win.Calendar.DrawDayEventArgs e)
{
if (e.Month == 6 & e.Day == 4)
{
Brush myBrush = Brushes.Red;
e.DrawBackground();
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Far;
format.LineAlignment = StringAlignment.Center;
e.Graphics.DrawString("休", new Font("MS ゴシック", 9), myBrush, e.Bounds, format);
e.Graphics.DrawImage(new Bitmap(@"c:\icon.png"), new Point(e.Bounds.X, e.Bounds.Y));
}
else
{
e.DrawBackground();
e.DrawTodayImageAndFocusRectangle();
e.DrawForeground();
}
}