PowerTools PlusPak for Windows Forms 8.0J
DrawFocusRectangle メソッド (DrawDayEventArgs)
使用例 

フォーカスのある日付領域のフォーカス矩形を描画します。
構文
Public Sub DrawFocusRectangle() 
public void DrawFocusRectangle()
使用例

次のサンプルコードは、GcCalendar コントロールの日付領域をオーナー描画する方法を示します。このコードは、DrawDay イベントを使用して各日付領域を GcCalendar に描画します。イベントハンドラにパラメーターとして渡された DrawDayEventArgs クラスのプロパティとメソッドを使用して日付領域を描画しています。このサンプルは、gcCalendar1 という名前の GcCalendar コントロールをすでにフォームに追加し、DrawDay イベントが以下のサンプルコードで定義されたイベントハンドラによって処理されるよう設定していることを前提とします。また、gcCalendar1 を CalendarType.MonthDay および OwnerDrawDay モードで初期化していることも前提とします。

private void gcCalendar1_DrawDay(object sender, GrapeCity.Win.Calendar.DrawDayEventArgs e)
{
    // Get the DateTime for current day view.
    DateTime drawingDay = new DateTime(e.Year, e.Month, e.Day);

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

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

    // Determine whether or not the current day view is Sunday.
    bool isSunday = drawingDay.DayOfWeek == System.DayOfWeek.Sunday;

    // Determine the color of the brush to draw different kinds of day view.
    if (e.IsTrailingDay)
    {
        myBrush = Brushes.Gray;
    }
    else if (isSunday)
    {
        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 today image for today day view.
    if (drawingDay == DateTime.Today)
    {
        e.DrawTodayImage();
    }

    // Draw focus rectangle for focused day view.
    if (drawingDay == gcCalendar1.FocusDate.BaseDate)
    {
        e.DrawFocusRectangle();
    }
}
Private Sub gcCalendar1_DrawDay(ByVal sender As Object, ByVal e As Global.GrapeCity.Win.Calendar.DrawDayEventArgs)
    ' Get the DateTime for current day view.
    Dim drawingDay As New DateTime(e.Year, e.Month, e.Day)

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

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

    ' Determine the color of the brush to draw different kinds of day view.
    If e.IsTrailingDay Then
        myBrush = Brushes.Gray
    ElseIf drawingDay.DayOfWeek = System.DayOfWeek.Sunday 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 today image for today day view.
    If drawingDay = DateTime.Today Then
        e.DrawTodayImage()
    End If

    ' Draw focus rectangle for focused day view.
    If drawingDay = gcCalendar1.FocusDate.BaseDate 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

参照

DrawDayEventArgs クラス
DrawDayEventArgs メンバ

Send Feedback