作成日: 2020/06/16 最終更新日: 2020/06/16
文書種別
使用方法
詳細
C1Scheduleでは、AppointmentのTextはHtml形式をサポートしています。そのため、BeforeAppointmentFormatイベント内で、指定した条件を満たすAppointmentに対して e.TextにHtmlを用いたレイアウトを指定することで、特定の予定の文字色や罫線の幅・色などを設定することができます。
以下に、指定日以降の予定、またはタイトルが特定文字列を含む予定に、文字色および罫線の幅・色を設定するサンプルを記載します。
◎サンプルコード(VB)
以下に、指定日以降の予定、またはタイトルが特定文字列を含む予定に、文字色および罫線の幅・色を設定するサンプルを記載します。
◎サンプルコード(VB)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
C1Schedule1.CalendarInfo.TimeInterval = C1.C1Schedule.TimeScaleEnum.OneHour
C1Schedule1.ViewType = C1.Win.C1Schedule.ScheduleViewEnum.DayView '日ビュー
'C1Schedule1.ViewType = C1.Win.C1Schedule.ScheduleViewEnum.WeekView '週ビュー
Dim app1 As C1.C1Schedule.Appointment = C1Schedule1.DataStorage.AppointmentStorage.Appointments.Add()
app1.Start = DateTime.Today().AddHours(9)
app1.End = app1.Start.AddHours(1)
app1.Subject = "2020年度_月例会"
app1.Location = "1階大会議室"
Dim app2 As C1.C1Schedule.Appointment = C1Schedule1.DataStorage.AppointmentStorage.Appointments.Add()
app2.Start = app1.Start.AddDays(1)
app2.End = app2.Start.AddHours(1)
app2.Subject = "部門ミーティング"
app2.Location = "1階小会議室"
C1Schedule1.Refresh()
End Sub
Private Sub C1Schedule1_BeforeAppointmentFormat(sender As Object, e As C1.Win.C1Schedule.BeforeAppointmentFormatEventArgs) Handles C1Schedule1.BeforeAppointmentFormat
If e.Appointment.Start > DateTime.Today().AddHours(12) Then
e.Text = "<p style=color:red;border-color:darkred;border-bottom-width:2;border-top-width:2;border-right-width:4;border-left-width:4>" & e.Text & "</>"
End If
If e.Text.Contains("月例会") Then
e.Text = "<p style=color:darkgreen;border-color:lightgreen;border-bottom-width:2;border-top-width:2;border-right-width:4;border-left-width:4>" & e.Text & "</>"
End If
End Sub
◎サンプルコード(C#) private void Form1_Load(object sender, EventArgs e)
{
c1Schedule1.CalendarInfo.TimeInterval = C1.C1Schedule.TimeScaleEnum.OneHour;
c1Schedule1.ViewType = C1.Win.C1Schedule.ScheduleViewEnum.DayView; //日ビュー
//c1Schedule1.ViewType = C1.Win.C1Schedule.ScheduleViewEnum.WeekView; //週ビュー
C1.C1Schedule.Appointment app1 = c1Schedule1.DataStorage.AppointmentStorage.Appointments.Add();
app1.Start = DateTime.Today.AddHours(9);
app1.End = app1.Start.AddHours(1);
app1.Subject = "2020年度_月例会";
app1.Location = "1階大会議室";
C1.C1Schedule.Appointment app2 = c1Schedule1.DataStorage.AppointmentStorage.Appointments.Add();
app2.Start = app1.Start.AddDays(1);
app2.End = app2.Start.AddHours(1);
app2.Subject = "部門ミーティング";
app2.Location = "1階小会議室";
c1Schedule1.Refresh();
}
private void c1Schedule1_BeforeAppointmentFormat(object sender, C1.Win.C1Schedule.BeforeAppointmentFormatEventArgs e)
{
if ((e.Appointment.Start > DateTime.Today.AddHours(12)))
{
e.Text = ("<p style=color:red;border-color:darkred;border-bottom-width:2;border-top-width:2;border-right-width:4;border-left-width:4>" + (e.Text + "</>"));
}
if (e.Text.Contains("月例会"))
{
e.Text = ("<p style=color:darkgreen;border-color:lightgreen;border-bottom-width:2;border-top-width:2;border-right-width:4;border-left-width:4>" + (e.Text + "</>"));
}
}
旧文書番号
85720