作成日: 2017/07/26 最終更新日: 2017/07/26
文書種別
使用方法
詳細
アクティブなセルは常に透過色が設定されるため、SelectionBackColorとSelectionForeColorプロパティを設定した場合でも、セルに設定されている背景色と文字色が表示されます。
アクティブなセルに選択色を表示するには、下記のように現在のセルのスタイルを設定してください。
[Visual Basic]
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' 選択色の定義
GcCalendarGrid1.Styles("defaultStyle").SelectionBackColor = Color.LightBlue
GcCalendarGrid1.Styles("defaultStyle").SelectionForeColor = Color.White
' フォーム表示時のアクティブなセルの色を設定する
GcCalendarGrid1.Content(DateTime.Today).Rows(0).Cells(0).CellStyle.BackColor = Color.LightBlue
GcCalendarGrid1.Content(DateTime.Today).Rows(0).Cells(0).CellStyle.ForeColor = Color.White
End Sub
Private Sub GcCalendarGrid1_CurrentCellPositionChanging(sender As Object, e As GrapeCity.Win.CalendarGrid.CalendarCellPositionChangingEventArgs) Handles GcCalendarGrid1.CurrentCellPositionChanging
' 現在のセルの外観を設定する
If (e.OldCellPosition.Scope = GrapeCity.Win.CalendarGrid.CalendarTableScope.Content And Not e.OldCellPosition.IsEmpty) Then
GcCalendarGrid1(e.OldCellPosition.Date)(e.OldCellPosition.RowIndex, e.OldCellPosition.ColumnIndex).CellStyle.BackColor = Color.Empty
GcCalendarGrid1(e.OldCellPosition.Date)(e.OldCellPosition.RowIndex, e.OldCellPosition.ColumnIndex).CellStyle.ForeColor = Color.Empty
End If
If (e.NewCellPosition.Scope = GrapeCity.Win.CalendarGrid.CalendarTableScope.Content And Not e.NewCellPosition.IsEmpty) Then
GcCalendarGrid1(e.NewCellPosition.Date)(e.NewCellPosition.RowIndex, e.NewCellPosition.ColumnIndex).CellStyle.BackColor = Color.LightBlue
GcCalendarGrid1(e.NewCellPosition.Date)(e.NewCellPosition.RowIndex, e.NewCellPosition.ColumnIndex).CellStyle.ForeColor = Color.White
End If
End Sub
[C#]
private void Form1_Load(object sender, EventArgs e)
{
// 選択色の定義
gcCalendarGrid1.Styles["defaultStyle"].SelectionBackColor = Color.LightBlue;
gcCalendarGrid1.Styles["defaultStyle"].SelectionForeColor = Color.White;
// フォーム表示時のアクティブなセルの色を設定する
gcCalendarGrid1.Content[DateTime.Today].Rows[0].Cells[0].CellStyle.BackColor = Color.LightBlue;
gcCalendarGrid1.Content[DateTime.Today].Rows[0].Cells[0].CellStyle.ForeColor = Color.White;
}
private void gcCalendarGrid1_CurrentCellPositionChanging(object sender, GrapeCity.Win.CalendarGrid.CalendarCellPositionChangingEventArgs e)
{
// 現在のセルの外観を設定する
if ((e.OldCellPosition.Scope == GrapeCity.Win.CalendarGrid.CalendarTableScope.Content & !e.OldCellPosition.IsEmpty))
{
gcCalendarGrid1[e.OldCellPosition.Date][e.OldCellPosition.RowIndex, e.OldCellPosition.ColumnIndex].CellStyle.BackColor = Color.Empty;
gcCalendarGrid1[e.OldCellPosition.Date][e.OldCellPosition.RowIndex, e.OldCellPosition.ColumnIndex].CellStyle.ForeColor = Color.Empty;
}
if ((e.NewCellPosition.Scope == GrapeCity.Win.CalendarGrid.CalendarTableScope.Content & !e.NewCellPosition.IsEmpty))
{
gcCalendarGrid1[e.NewCellPosition.Date][e.NewCellPosition.RowIndex, e.NewCellPosition.ColumnIndex].CellStyle.BackColor = Color.LightBlue;
gcCalendarGrid1[e.NewCellPosition.Date][e.NewCellPosition.RowIndex, e.NewCellPosition.ColumnIndex].CellStyle.ForeColor = Color.White;
}
}
アクティブなセルに選択色を表示するには、下記のように現在のセルのスタイルを設定してください。
[Visual Basic]
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' 選択色の定義
GcCalendarGrid1.Styles("defaultStyle").SelectionBackColor = Color.LightBlue
GcCalendarGrid1.Styles("defaultStyle").SelectionForeColor = Color.White
' フォーム表示時のアクティブなセルの色を設定する
GcCalendarGrid1.Content(DateTime.Today).Rows(0).Cells(0).CellStyle.BackColor = Color.LightBlue
GcCalendarGrid1.Content(DateTime.Today).Rows(0).Cells(0).CellStyle.ForeColor = Color.White
End Sub
Private Sub GcCalendarGrid1_CurrentCellPositionChanging(sender As Object, e As GrapeCity.Win.CalendarGrid.CalendarCellPositionChangingEventArgs) Handles GcCalendarGrid1.CurrentCellPositionChanging
' 現在のセルの外観を設定する
If (e.OldCellPosition.Scope = GrapeCity.Win.CalendarGrid.CalendarTableScope.Content And Not e.OldCellPosition.IsEmpty) Then
GcCalendarGrid1(e.OldCellPosition.Date)(e.OldCellPosition.RowIndex, e.OldCellPosition.ColumnIndex).CellStyle.BackColor = Color.Empty
GcCalendarGrid1(e.OldCellPosition.Date)(e.OldCellPosition.RowIndex, e.OldCellPosition.ColumnIndex).CellStyle.ForeColor = Color.Empty
End If
If (e.NewCellPosition.Scope = GrapeCity.Win.CalendarGrid.CalendarTableScope.Content And Not e.NewCellPosition.IsEmpty) Then
GcCalendarGrid1(e.NewCellPosition.Date)(e.NewCellPosition.RowIndex, e.NewCellPosition.ColumnIndex).CellStyle.BackColor = Color.LightBlue
GcCalendarGrid1(e.NewCellPosition.Date)(e.NewCellPosition.RowIndex, e.NewCellPosition.ColumnIndex).CellStyle.ForeColor = Color.White
End If
End Sub
[C#]
private void Form1_Load(object sender, EventArgs e)
{
// 選択色の定義
gcCalendarGrid1.Styles["defaultStyle"].SelectionBackColor = Color.LightBlue;
gcCalendarGrid1.Styles["defaultStyle"].SelectionForeColor = Color.White;
// フォーム表示時のアクティブなセルの色を設定する
gcCalendarGrid1.Content[DateTime.Today].Rows[0].Cells[0].CellStyle.BackColor = Color.LightBlue;
gcCalendarGrid1.Content[DateTime.Today].Rows[0].Cells[0].CellStyle.ForeColor = Color.White;
}
private void gcCalendarGrid1_CurrentCellPositionChanging(object sender, GrapeCity.Win.CalendarGrid.CalendarCellPositionChangingEventArgs e)
{
// 現在のセルの外観を設定する
if ((e.OldCellPosition.Scope == GrapeCity.Win.CalendarGrid.CalendarTableScope.Content & !e.OldCellPosition.IsEmpty))
{
gcCalendarGrid1[e.OldCellPosition.Date][e.OldCellPosition.RowIndex, e.OldCellPosition.ColumnIndex].CellStyle.BackColor = Color.Empty;
gcCalendarGrid1[e.OldCellPosition.Date][e.OldCellPosition.RowIndex, e.OldCellPosition.ColumnIndex].CellStyle.ForeColor = Color.Empty;
}
if ((e.NewCellPosition.Scope == GrapeCity.Win.CalendarGrid.CalendarTableScope.Content & !e.NewCellPosition.IsEmpty))
{
gcCalendarGrid1[e.NewCellPosition.Date][e.NewCellPosition.RowIndex, e.NewCellPosition.ColumnIndex].CellStyle.BackColor = Color.LightBlue;
gcCalendarGrid1[e.NewCellPosition.Date][e.NewCellPosition.RowIndex, e.NewCellPosition.ColumnIndex].CellStyle.ForeColor = Color.White;
}
}
旧文書番号
40741