作成日: 2022/03/11 最終更新日: 2022/03/30
文書種別
使用方法
詳細
ダイナミック セルスタイルのDynamicCellStyleConditionHandlerでセルの情報を取得するには、context.GcMultiRowプロパティで呼び出し元のGcMultiRowコントロールを参照します。なお、セルの情報がTemplateから変化しないことが前提の場合は、context.Template.Row.Cellsプロパティを参照するほうが効率的です。
[Visual Basic]
[C#]
[Visual Basic]
Imports GrapeCity.Win.MultiRow Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 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 = 3 End Sub Private Function MyCondition(ByVal context As DynamicCellStyleContext) As CellStyle Dim newCellStyle As New CellStyle() If context.GcMultiRow(context.RowIndex, context.CellIndex).Enabled = False Then ' ここにスタイルを変更するコードを追加します End If Return newCellStyle 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 = 3;
}
private CellStyle MyCondition(DynamicCellStyleContext context)
{
CellStyle newCellStyle = new CellStyle();
if (context.GcMultiRow[context.RowIndex, context.CellIndex].Enabled == false)
{
// ここにスタイルを変更するコードを追加します
}
return newCellStyle;
}