新規行のセルスタイルを設定する方法
対象製品
MultiRow for Windows Forms 10.0J
詳細
次のコードはダイナミック セルスタイルを使用して新規行のセルスタイルを変更します。
[Visual Basic]
[C#]
[Visual Basic]
Imports GrapeCity.Win.MultiRow Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dynamicCellStyle1 As New DynamicCellStyle() dynamicCellStyle1.ConditionHandler = New DynamicCellStyleConditionHandler(AddressOf MyCondition) Dim template1 As Template = Template.Default template1.Row.DefaultCellStyle = dynamicCellStyle1 GcMultiRow1.Template = template1 GcMultiRow1.RowCount = 2 End Sub Private Function MyCondition(ByVal context As DynamicCellStyleContext) As CellStyle Dim style As New CellStyle() If context.GcMultiRow.NewRowIndex = context.RowIndex Then If Not context.GcMultiRow.CurrentCellPosition.RowIndex = context.RowIndex OrElse context.GcMultiRow.EditingControl Is Nothing Then style.BackColor = Color.Azure End If End If Return style End Function
[C#]
using GrapeCity.Win.MultiRow; private void Form1_Load(object sender, EventArgs e) { DynamicCellStyle dynamicCellStyle1 = new DynamicCellStyle(); dynamicCellStyle1.ConditionHandler = new DynamicCellStyleConditionHandler(MyCondition); Template template1 = Template.Default; template1.Row.DefaultCellStyle = dynamicCellStyle1; gcMultiRow1.Template = template1; gcMultiRow1.RowCount = 2; } private CellStyle MyCondition(DynamicCellStyleContext context) { CellStyle style = new CellStyle(); if (context.GcMultiRow.NewRowIndex == context.RowIndex) { if (context.GcMultiRow.CurrentCellPosition.RowIndex != context.RowIndex || context.GcMultiRow.EditingControl == null) { style.BackColor = Color.Azure; } } return style; }