選択範囲を透過してコンテンツを表示するには?

文書番号 : 40572     文書種別 : 使用方法     登録日 : 2017/07/26     最終更新日 : 2017/07/26
文書を印刷する
対象製品
MultiRow for Windows Forms 10.0J
詳細
選択範囲に透過色を使用するには、CellStyle.SelectionBackColorプロパティのColorでアルファ値を指定します。セルのコンテンツの文字色を選択色に反映するには、CellStyle.SelectionForeColorプロパティにCellStyle.ForeColorプロパティと同じ色を指定します。

[Visual Basic]
Imports GrapeCity.Win.MultiRow

Private _selectionBackColor As Color
Private _rowIndex As Integer
Private _cellIndex As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    GcMultiRow1.Template = Template.CreateGridTemplate(10)
    GcMultiRow1.RowCount = 20

    _selectionBackColor = GcMultiRow1.CurrentCell.Style.SelectionBackColor
    _rowIndex = GcMultiRow1.CurrentCell.RowIndex
    _cellIndex = GcMultiRow1.CurrentCell.CellIndex

    GcMultiRow1.DefaultCellStyle.SelectionForeColor = GcMultiRow1.DefaultCellStyle.ForeColor
    GcMultiRow1.DefaultCellStyle.SelectionBackColor = Color.FromArgb(75, 228, 228, 232)

    GcMultiRow1(2, 2).Style.BackColor = Color.Red
    GcMultiRow1(1, 1).Value = "Testing"
    GcMultiRow1(1, 1).Style.ForeColor = Color.Red
    GcMultiRow1(1, 1).Style.SelectionForeColor = Color.Red

    SelectionActions.SelectAll.Execute(GcMultiRow1)
End Sub

Private Sub GcMultiRow1_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GcMultiRow1.CurrentCellChanged
    Dim gcMultiRow As GcMultiRow = TryCast(sender, GcMultiRow)
    gcMultiRow(_rowIndex, _cellIndex).Style.SelectionBackColor = _selectionBackColor

    _selectionBackColor = gcMultiRow.CurrentCell.Style.SelectionBackColor
    _rowIndex = gcMultiRow.CurrentCell.RowIndex
    _cellIndex = gcMultiRow.CurrentCell.CellIndex

    If gcMultiRow.CurrentCell.Style.BackColor = Color.Empty Then
        gcMultiRow.CurrentCell.Style.SelectionBackColor = gcMultiRow.CurrentRow.BackColor
    Else
        gcMultiRow.CurrentCell.Style.SelectionBackColor = gcMultiRow.CurrentCell.Style.BackColor
    End If
End Sub

[C#]
using GrapeCity.Win.MultiRow;

private Color _selectionBackColor;
private int _rowIndex;
private int _cellIndex;

private void Form1_Load(object sender, EventArgs e)
{
    gcMultiRow1.Template = Template.CreateGridTemplate(10);
    gcMultiRow1.RowCount = 20;
    
    _selectionBackColor = gcMultiRow1.CurrentCell.Style.SelectionBackColor;
    _rowIndex = gcMultiRow1.CurrentCell.RowIndex;
    _cellIndex = gcMultiRow1.CurrentCell.CellIndex;

    gcMultiRow1.DefaultCellStyle.SelectionForeColor = gcMultiRow1.DefaultCellStyle.ForeColor;
    gcMultiRow1.DefaultCellStyle.SelectionBackColor = Color.FromArgb(75, 228, 228, 232);

    gcMultiRow1[2, 2].Style.BackColor = Color.Red;
    gcMultiRow1[1, 1].Value = "Testing";
    gcMultiRow1[1, 1].Style.ForeColor = Color.Red;
    gcMultiRow1[1, 1].Style.SelectionForeColor = Color.Red;

    gcMultiRow1.CurrentCellChanged += new EventHandler(gcMultiRow1_CurrentCellChanged);
    
    SelectionActions.SelectAll.Execute(gcMultiRow1);
}

private void gcMultiRow1_CurrentCellChanged(object sender, EventArgs e)
{
    GcMultiRow gcMultiRow = sender as GcMultiRow;
    gcMultiRow[_rowIndex, _cellIndex].Style.SelectionBackColor = _selectionBackColor;

    _selectionBackColor = gcMultiRow.CurrentCell.Style.SelectionBackColor;
    _rowIndex = gcMultiRow.CurrentCell.RowIndex;
    _cellIndex = gcMultiRow.CurrentCell.CellIndex;

    if (gcMultiRow.CurrentCell.Style.BackColor == Color.Empty)
        gcMultiRow.CurrentCell.Style.SelectionBackColor = gcMultiRow.CurrentRow.BackColor;
    else
        gcMultiRow.CurrentCell.Style.SelectionBackColor = gcMultiRow.CurrentCell.Style.BackColor;
}