PowerTools PlusPak for Windows Forms 8.0J
Graphics プロパティ (DrawMonthEventArgs)
使用例 

月に描画するグラフィック表面を取得します。
構文
Public ReadOnly Property Graphics As Graphics
public Graphics Graphics {get;}

プロパティ値

月に描画するSystem.Drawing.Graphics
使用例

次のサンプルコードは、GcCalendarコントロールにオーナードローの月領域を描画する方法を示します。コードでは、DrawMonthイベントを使用してGcCalendarの各月領域へ描画を行います。サンプルコードは、イベントハンドラのパラメーターとして渡されたDrawMonthEventArgsクラスのプロパティとメソッドを使用して月部分を描画します。この例では、フォームにすでにgcCalendar1という名前のGcCalendarコントロールが追加されていることを前提とします。DrawMonthイベントがサンプルコードで定義されたイベントハンドラに処理されている必要があります。また、gcCalendar1がCalendarType.YearMonth および CalendarDrawMode.OwnerDrawMonth モードで初期化されることを条件とします。

private void gcCalendar1_DrawMonth(object sender, GrapeCity.Win.Calendar.DrawMonthEventArgs e)
{
    // Draw the background of current day view.
    e.DrawBackground();

    // Define the default color of the brush as black.
    Brush myBrush = Brushes.Black;

    if (e.Month == DateTime.Now.Month)
    {
        myBrush = Brushes.Red;
    }

    // Define the format of text being drawn.
    StringFormat format = new StringFormat();
    format.Alignment = StringAlignment.Far;
    format.LineAlignment = StringAlignment.Center;

    // Draw the current day view text based on the current Font and the custom brush settings.
    e.Graphics.DrawString(e.Text, gcCalendar1.Font, myBrush, e.Bounds, format);

    // Draw the focus rectangle around the focus date.
    if (e.Month == gcCalendar1.FocusDate.Month)
    {
        e.DrawFocusRectangle();
    }
}
Private Sub gcCalendar1_DrawMonth(ByVal sender As Object, ByVal e As Global.GrapeCity.Win.Calendar.DrawMonthEventArgs)

    ' Draw the background of current day view.
    e.DrawBackground()

    ' Define the default color of the brush as black.
    Dim myBrush As Brush = Brushes.Black

    If e.Month = DateTime.Now.Month Then
        myBrush = Brushes.Red
    End If

    ' Define the format of text being drawn.
    Dim format As New StringFormat()
    format.Alignment = StringAlignment.Far
    format.LineAlignment = StringAlignment.Center

    ' Draw the current day view text based on the current Font and the custom brush settings.
    e.Graphics.DrawString(e.Text, gcCalendar1.Font, myBrush, e.Bounds, format)

    ' Draw the focus rectangle around the focus date.
    If e.Month = gcCalendar1.FocusDate.Month Then
        e.DrawFocusRectangle()
    End If
End Sub
プラットフォーム

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

参照

DrawMonthEventArgs クラス
DrawMonthEventArgs メンバ

Send Feedback