PowerTools MultiRow for Windows Forms 8.0J
DynamicCellStyle クラス
メンバ  使用例 

Public Class DynamicCellStyle 
   Inherits CellStyle
public class DynamicCellStyle : CellStyle 
using System;
using System.Windows.Forms;
using System.Drawing;

namespace GrapeCity.Win.MultiRow.SampleCode
    public class DynamicCellStyleDemo : Form
        private GcMultiRow gcMultiRow1 = new GcMultiRow();

        public DynamicCellStyleDemo()
            this.gcMultiRow1.Dock = DockStyle.Fill;
            this.Load += new EventHandler(Form1_Load);
            this.Text = "DynamicCellStyle Demo (If any cell's value is not empty, color will change)";
            this.Size = new Size(700, 400);
        private void Form1_Load(object sender, EventArgs e)

            Template template1 = Template.CreateGridTemplate(7);

            DynamicCellStyle dynamicCellStyle1 = new DynamicCellStyle();
            dynamicCellStyle1.ConditionHandler += new DynamicCellStyleConditionHandler(GetNewRowDefaultCellStyle);

            template1.Row.DefaultCellStyle = dynamicCellStyle1;

            gcMultiRow1.Template = template1;
            gcMultiRow1.RowCount = 10;

        public CellStyle GetNewRowDefaultCellStyle(DynamicCellStyleContext context)
            CellStyle newRowDefaultCellStyle = new CellStyle();

            // If all cell's value in a specific row are empty, the cell's back color is white, otherwise color is yellow.
            newRowDefaultCellStyle.BackColor = Color.White;
            if (context.CellScope == CellScope.Row)
                for (int i = 0; i < context.GcMultiRow.Rows[context.RowIndex].Cells.Count; i++)
                    object value = context.GcMultiRow.Rows[context.RowIndex][i].Value;

                    if (value != null)
                        newRowDefaultCellStyle.BackColor = Color.Yellow;
            return newRowDefaultCellStyle;

        public static void Main()
            Application.Run(new DynamicCellStyleDemo());
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports GrapeCity.Win.MultiRow

Public Class DynamicCellStyleDemo
    Inherits Form
    Private gcMultiRow1 As New GcMultiRow()

    Public Sub New()
        Me.gcMultiRow1.Dock = DockStyle.Fill
        Me.Text = "DynamicCellStyle Demo (If any cell's value is not empty, color will change)"
        Me.Size = New Size(700, 400)
    End Sub
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        Dim template1 As Template = Template.CreateGridTemplate(7)

        Dim dynamicCellStyle1 As New DynamicCellStyle()
        dynamicCellStyle1.ConditionHandler = AddressOf Me.GetNewRowDefaultCellStyle

        template1.Row.DefaultCellStyle = dynamicCellStyle1

        gcMultiRow1.Template = template1
        gcMultiRow1.RowCount = 10
    End Sub

    Public Function GetNewRowDefaultCellStyle(ByVal context As DynamicCellStyleContext) As CellStyle
        Dim newRowDefaultCellStyle As New CellStyle()

        ' If all cell's value in a specific row are empty, the cell's back color is white, otherwise color is yellow.
        newRowDefaultCellStyle.BackColor = Color.White
        If context.CellScope = CellScope.Row Then

            For i As Integer = 0 To context.GcMultiRow.Rows(context.RowIndex).Cells.Count - 1
                Dim value As Object = context.GcMultiRow.Rows(context.RowIndex)(i).Value
                If value <> Nothing Then
                    newRowDefaultCellStyle.BackColor = Color.Yellow
                    Exit For
                End If
        End If
        Return newRowDefaultCellStyle
    End Function
    <STAThreadAttribute()> _
    Public Shared Sub Main()
        Application.Run(New DynamicCellStyleDemo())
    End Sub
End Class



DynamicCellStyle メンバ
GrapeCity.Win.MultiRow 名前空間
CellStyle クラス
DynamicCellStyleConditionHandler デリゲート
DynamicCellStyleContext クラス
NamedCellStyle クラス
ConditionalCellStyle クラス
CombinedCellStyle クラス



© 2008-2015 GrapeCity inc. All rights reserved.