作成日: 2026/06/02 最終更新日: 2026/06/02
文書種別
技術情報
詳細
パーセント型セルで入力可能な最大値を 99.9% に設定する場合、PercentCellTypeクラスのDecimalPlacesプロパティに1を設定した上で、MaximumValueプロパティに 99.9/100.0 を設定します。
※MaximumValueプロパティに0.999を設定した場合には、99.8%までしか入力ができず、99.9%は入力できません。これはMaximumValueプロパティがDouble型で管理されているために丸め誤差が発生して、 0.999 < 99.9/100.0 となるためです。
◎サンプルコード(VB)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' パーセント型セルの設定
Dim prctcell As New FarPoint.Win.Spread.CellType.PercentCellType
prctcell.DecimalPlaces = 1
prctcell.DecimalSeparator = "."
prctcell.FixedPoint = True
prctcell.MaximumValue = 99.9 / 100.0
prctcell.MinimumValue = 0.0
FpSpread1.ActiveSheet.Columns(0).CellType = prctcell
' Double型 小数検証
Dim a As Double = 99.9 / 100.0 ' 0.99900000000000011
Dim isSmaller As Boolean = 0.999 < a ' True
End Sub
◎サンプルコード(C#)
private void Form1_Load(object sender, EventArgs e)
{
// パーセント型セルの設定
FarPoint.Win.Spread.CellType.PercentCellType prctcell = new FarPoint.Win.Spread.CellType.PercentCellType();
prctcell.DecimalPlaces = 1;
prctcell.DecimalSeparator = ".";
prctcell.FixedPoint = true;
prctcell.MaximumValue = 99.9 / 100.0;
prctcell.MinimumValue = 0.0;
fpSpread1.ActiveSheet.Columns[0].CellType = prctcell;
// Double型 小数検証
double a = 99.9 / 100.0; // 0.99900000000000011
bool isSmaller = 0.999 < a; // true
}