PowerTools CalendarGrid for Windows Forms 1.0J
背景色と前景色

CalendarGridでは、セルの状態に応じて5種類の色を背景と前景にそれぞれ設定できます。


セルが非選択状態のときの色

セルが選択されていない状態の色は、CalendarCellStyle.BackColorプロパティとCalendarCellStyle.ForeColorプロパティで設定できます。

Dim today As DateTime = DateTime.Today

GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.BackColor = Color.LightBlue
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.ForeColor = Color.Blue
GcCalendarGrid1.ScrollIntoView(today)
var today = DateTime.Today;

gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.BackColor = Color.LightBlue;
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.ForeColor = Color.Blue;
gcCalendarGrid1.ScrollIntoView(today);

結果は次のようになります。


セルが選択状態のときの色

セルが選択されている状態の色は、CalendarCellStyle.SelectionBackColorプロパティとCalendarCellStyle.SelectionForeColorプロパティで設定します。

Dim today As DateTime = DateTime.Today

GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.SelectionBackColor = Color.LightBlue
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.SelectionForeColor = Color.Blue
GcCalendarGrid1.ScrollIntoView(today)
var today = DateTime.Today;

gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.SelectionBackColor = Color.LightBlue;
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.SelectionForeColor = Color.Blue;
gcCalendarGrid1.ScrollIntoView(today);


セルが編集状態のときの色

セルが編集状態の時の色は、CalendarCellStyle.EditingBackColorプロパティとCalendarCellStyle.EditingForeColorプロパティで設定します。

Dim today As DateTime = DateTime.Today

GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.EditingBackColor = Color.LightBlue
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.EditingForeColor = Color.Blue
GcCalendarGrid1.ScrollIntoView(today)
var today = DateTime.Today;

gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.EditingBackColor = Color.LightBlue;
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.EditingForeColor = Color.Blue;
gcCalendarGrid1.ScrollIntoView(today);


セルが無効状態のときの色

セルが無効の時(CalendarCell.EnabledプロパティがFalseのとき)の色は、CalendarCellStyle.DisabledBackColorプロパティとCalendarCellStyle.DisabledForeColorプロパティで設定します。

Dim today As DateTime = DateTime.Today

GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.DisabledBackColor = Color.LightBlue
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.DisabledForeColor = Color.Blue
GcCalendarGrid1.Content(today).Rows(1).Cells(0).Enabled = False
GcCalendarGrid1.ScrollIntoView(today)
var today = DateTime.Today;

gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.DisabledBackColor = Color.LightBlue;
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.DisabledForeColor = Color.Blue;
gcCalendarGrid1.Content[today].Rows[1].Cells[0].Enabled = false;
gcCalendarGrid1.ScrollIntoView(today);


セルがマウスオーバー状態のときの色

セルの上にマウスカーソルがあるときの色は、CalendarCellStyle.MouseOverBackColorプロパティとCalendarCellStyle.MouseOverForeColorプロパティで設定します。

Dim today As DateTime = DateTime.Today

GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.MouseOverBackColor = Color.LightBlue
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.MouseOverForeColor = Color.Blue
GcCalendarGrid1.ScrollIntoView(today)
var today = DateTime.Today;

gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.MouseOverBackColor = Color.LightBlue;
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.MouseOverForeColor = Color.Blue;
gcCalendarGrid1.ScrollIntoView(today);


背景グラデーションと背景色

背景グラデーションは背景色よりも優先されます。次のコードでは、指定した赤色の背景色よりも青いグラデーションが優先して表示されます。

Imports GrapeCity.Win.CalendarGrid

Dim today As DateTime = DateTime.Today
Dim gradientEffect As New CalendarGradientEffect(CalendarGradientStyle.Vertical, CalendarGradientDirection.Forward, Color.DarkBlue, Color.LightBlue)
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.BackgroundGradientEffect = gradientEffect
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.BackColor = Color.Red
GcCalendarGrid1.ScrollIntoView(today)
using GrapeCity.Win.CalendarGrid;

var today = DateTime.Today;
var gradientEffect = new CalendarGradientEffect(CalendarGradientStyle.Vertical, CalendarGradientDirection.Forward, Color.DarkBlue, Color.LightBlue);
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.BackgroundGradientEffect = gradientEffect;
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.BackColor = Color.Red;
gcCalendarGrid1.ScrollIntoView(today);

結果は次のようになります。

選択状態ではCalendarCellStyle.SelectionGradientEffect、マウスオーバー時にはCalendarCellStyle.MouseOverGradientEffectプロパティをそれぞれ利用できます。


背景パターン

セルには背景色と背景グラデーションの手前に背景パターンを設定できます。背景パターンでサポートされている外観は、.NET Framework で提供されている背景パターン(System.Drawing.Drawing2D.HatchStyle)と同一です。

Imports GrapeCity.Win.CalendarGrid

Dim today As DateTime = DateTime.Today
Dim patternStyle As New CalendarPatternEffect(CalendarPatternStyle.Percent10, Color.Green)
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.PatternEffect = patternStyle
GcCalendarGrid1.ScrollIntoView(today)
using GrapeCity.Win.CalendarGrid;

var today = DateTime.Today;
var patternStyle = new CalendarPatternEffect(CalendarPatternStyle.Percent10, Color.Green);
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.PatternEffect = patternStyle;
gcCalendarGrid1.ScrollIntoView(today);

結果は次のようになります。

選択状態やマウスオーバー時に異なる背景パターンを表示することはできません。


ビジュアルスタイルと背景色

ビジュアル スタイルが有効な環境では、セル型のFlatStyleプロパティがSystemに設定されているか、セル型のUseVisualStyleBackColor プロパティがTrueの場合にはBackColor プロパティに設定した背景色は適用されません。これはButton型セルとHeader型セルが該当します。

参照

 

 


© 2014 GrapeCity inc. All rights reserved.