端数処理をするには、RoundPatternプロパティを使用します。
プロパティの値 |
説明 |
Ceiling |
切り上げ |
Floor |
切り捨て |
MidpointRoundAwayFromZero |
四捨五入 |
MidpointRoundToEven |
近似値への丸め(偶数丸め、銀行丸め) |
None |
端数処理なし |
また、RoundDigitsプロパティで端数処理後の小数点以下の桁数を設定できます。
以下のコードでは、小数点以下の2桁目の値を切り捨てます。
Imports GrapeCity.Win.MultiRow
Dim SummaryCell1 As New SummaryCell()
SummaryCell1.RoundDigits = 1
SummaryCell1.RoundPattern = RoundPattern.Floor
using GrapeCity.Win.MultiRow;
SummaryCell summaryCell1 = new SummaryCell();
summaryCell1.RoundDigits = 1;
summaryCell1.RoundPattern = RoundPattern.Floor;
上記「デザイナによる設定」と同じ設定をコーディングで行う場合は、次のコードになります。
Imports GrapeCity.Win.MultiRow
Dim NumericUpDownCell1 As New NumericUpDownCell()
NumericUpDownCell1.Name = "NumericUpDownCell1"
NumericUpDownCell1.Value = 4
Dim NumericUpDownCell2 = New NumericUpDownCell()
NumericUpDownCell2.Name = "NumericUpDownCell2"
NumericUpDownCell2.Value = 3
Dim Expression1 As New Expression()
Expression1.ExpressionString = "NumericUpDownCell1 / NumericUpDownCell2"
Dim SummaryCell1 As New SummaryCell()
SummaryCell1.Name = "SummaryCell1"
SummaryCell1.Calculation = Expression1
SummaryCell1.RoundDigits = 2
SummaryCell1.RoundPattern = RoundPattern.Ceiling
Dim cells As Cell() = {NumericUpDownCell1, NumericUpDownCell2, SummaryCell1}
Dim Template1 As Template = Template.CreateGridTemplate(cells)
GcMultiRow1.Template = Template1
using GrapeCity.Win.MultiRow;
NumericUpDownCell numericUpDownCell1 = new NumericUpDownCell();
numericUpDownCell1.Name = "numericUpDownCell1";
numericUpDownCell1.Value = 4;
NumericUpDownCell numericUpDownCell2 = new NumericUpDownCell();
numericUpDownCell2.Name = "numericUpDownCell2";
numericUpDownCell2.Value = 3;
Expression expression1 = new Expression();
expression1.ExpressionString = "numericUpDownCell1 / numericUpDownCell2";
SummaryCell summaryCell1 = new SummaryCell();
summaryCell1.Calculation = expression1;
summaryCell1.RoundDigits = 2;
summaryCell1.RoundPattern = RoundPattern.Ceiling;
Cell[] cells = { numericUpDownCell1, numericUpDownCell2, summaryCell1 };
Template template1 = Template.CreateGridTemplate(cells);
gcMultiRow1.Template = template1;