- void gcNumber_Validated(object sender, EventArgs e)
- {
- GcNumber gcNumber = sender as GcNumber;
- if (gcNumber == null)
- {
- return;
- }
- var value = gcNumber.Value;
- if (!value.HasValue)
- {
- return;
- }
- var decimalValue = value.Value;
- var turncatedValue = decimal.Truncate(decimalValue);
- if (decimalValue == turncatedValue)
- {
- gcNumber.Clear();
- gcNumber.Value = turncatedValue;
- }
- }
复制代码 示意代码如上所示。 |