作成日: 2016/05/11 最終更新日: 2016/05/11
文書種別
制限事項
詳細
C1Calenderのテーマ項目のうち、「共通」(Common)や「今日」(DayToday)のフォントを以下のようにコードで設定しても、カレンダーの表示時に反映されません。
◎サンプルコード(VB)
◎サンプルコード(C#)
◎サンプルコード(VB)
‘ 「共通」の設定例
Dim theme As Theme = UI.CalendarTheme.Office2007Blue
theme.Item("Common").Font = New Font("MS UI Gothic", 16, FontStyle.Bold)
theme.Item("Common").ForeColor = Color.LimeGreen
C1Calendar1.Theme = theme
‘(参考)テーマ項目名の取得
For i As Int32 = 0 To theme.Count - 1
Console.WriteLine(theme.Item(i).Name)
Next
Dim theme As Theme = UI.CalendarTheme.Office2007Blue
theme.Item("Common").Font = New Font("MS UI Gothic", 16, FontStyle.Bold)
theme.Item("Common").ForeColor = Color.LimeGreen
C1Calendar1.Theme = theme
‘(参考)テーマ項目名の取得
For i As Int32 = 0 To theme.Count - 1
Console.WriteLine(theme.Item(i).Name)
Next
◎サンプルコード(C#)
// 「共通」の設定例
Theme theme = UI.CalendarTheme.Office2007Blue;
theme.Item("Common").Font = new Font("MS UI Gothic", 16, FontStyle.Bold);
theme.Item("Common").ForeColor = Color.LimeGreen;
C1Calendar1.Theme = theme;
//(参考)テーマ項目名の取得
for (Int32 i = 0; i <= theme.Count - 1; i++)
{
Console.WriteLine(theme.Item(i).Name);
}
Theme theme = UI.CalendarTheme.Office2007Blue;
theme.Item("Common").Font = new Font("MS UI Gothic", 16, FontStyle.Bold);
theme.Item("Common").ForeColor = Color.LimeGreen;
C1Calendar1.Theme = theme;
//(参考)テーマ項目名の取得
for (Int32 i = 0; i <= theme.Count - 1; i++)
{
Console.WriteLine(theme.Item(i).Name);
}
回避方法
これらは、本コンポーネントの仕様上の動作です。テーマ項目のうち、「共通」や「今日」では特殊なスタイル設定が必要です。
「共通」スタイルは1つのスタイルだけではなく、すべてのスタイルおよびテーマのプロパティと一緒に動作します。そのため、コードで設定する場合、以下のようにする必要があります。
◎サンプルコード(VB)
◎サンプルコード(C#)
「今日」スタイルは、テーマからそのまま適用はされません。実際の外観は、この日が「太字表示の日」であるか、選択されているか、「今月に該当しない日」であるかにも依存します。コードから「今日」の各種プロパティを変更するには、C1CalendarのBeforeDayFormatイベントを使用して、次のように設定してください。
◎サンプルコード(VB)
◎サンプルコード(C#)
なお、「共通」については、デザイン時に以下の場所で設定すると反映されます*。
* C1Calenderのスマートデザイナ >表示スタイル > カスタム > 「表示スタイル」ダイアログボックス
「共通」スタイルは1つのスタイルだけではなく、すべてのスタイルおよびテーマのプロパティと一緒に動作します。そのため、コードで設定する場合、以下のようにする必要があります。
◎サンプルコード(VB)
Dim theme As UI.CalendarTheme = UI.CalendarTheme.Office2007Blue
theme.BaseFont = New Font("MS UI Gothic", 16, FontStyle.Bold)
For Each s As Style In theme
s.ForeColor = Color.LimeGreen
Next
C1Calendar1.Theme = theme
theme.BaseFont = New Font("MS UI Gothic", 16, FontStyle.Bold)
For Each s As Style In theme
s.ForeColor = Color.LimeGreen
Next
C1Calendar1.Theme = theme
◎サンプルコード(C#)
UI.CalendarTheme theme = UI.CalendarTheme.Office2007Blue;
theme.BaseFont = new Font("MS UI Gothic", 16, FontStyle.Bold);
foreach (Style s in theme)
{
s.ForeColor = Color.LimeGreen;
}
C1Calendar1.Theme = theme;
theme.BaseFont = new Font("MS UI Gothic", 16, FontStyle.Bold);
foreach (Style s in theme)
{
s.ForeColor = Color.LimeGreen;
}
C1Calendar1.Theme = theme;
「今日」スタイルは、テーマからそのまま適用はされません。実際の外観は、この日が「太字表示の日」であるか、選択されているか、「今月に該当しない日」であるかにも依存します。コードから「今日」の各種プロパティを変更するには、C1CalendarのBeforeDayFormatイベントを使用して、次のように設定してください。
◎サンプルコード(VB)
Private Sub C1Calendar1_BeforeDayFormat(sender As Object, e As BeforeDayFormatEventArgs) Handles C1Calendar1.BeforeDayFormat
If e.Date.Equals(DateTime.Today) Then
e.Style.ForeColor = Color.PeachPuff
e.Style.Font = New Font("MS UI Gothic", 16, FontStyle.Bold)
e.Style.BackColor = Color.Violet
End If
End Sub
If e.Date.Equals(DateTime.Today) Then
e.Style.ForeColor = Color.PeachPuff
e.Style.Font = New Font("MS UI Gothic", 16, FontStyle.Bold)
e.Style.BackColor = Color.Violet
End If
End Sub
◎サンプルコード(C#)
private void C1Calendar1_BeforeDayFormat(object sender, BeforeDayFormatEventArgs e)
{
if (e.Date.Equals(DateTime.Today))
{
e.Style.ForeColor = Color.PeachPuff;
e.Style.Font = new Font("MS UI Gothic", 16, FontStyle.Bold);
e.Style.BackColor = Color.Violet;
}
}
{
if (e.Date.Equals(DateTime.Today))
{
e.Style.ForeColor = Color.PeachPuff;
e.Style.Font = new Font("MS UI Gothic", 16, FontStyle.Bold);
e.Style.BackColor = Color.Violet;
}
}
なお、「共通」については、デザイン時に以下の場所で設定すると反映されます*。
* C1Calenderのスマートデザイナ >表示スタイル > カスタム > 「表示スタイル」ダイアログボックス
旧文書番号
81648