728x90
반응형
728x170
using System;
using DevExpress.Xpf.Grid;
...
#region 단가 그리드 컬럼 값 검증하기 - unitPriceGridColumn_Validate(sender, e)
/// <summary>
/// 단가 그리드 컬럼 값 검증하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void unitPriceGridColumn_Validate(object sender, GridCellValidationEventArgs e)
{
Product product = e.Row as Product;
if(product == null)
{
return;
}
bool discontinued = product.Discontinued;
if(discontinued)
{
double newValue = Convert.ToDouble(pGridCellValidationEventArgs.Value );
double cellValue = Convert.ToDouble(pGridCellValidationEventArgs.CellValue);
double discount = 100d - (newValue * 100) / cellValue;
if(!(e.IsValid = dDiscount > 0 && discount <= 30d))
{
e.ErrorType = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical;
if(discount < 0)
{
e.ErrorContent = string.Format
(
"The price cannot be greater than ${0}",
Convert.ToDouble(e.CellValue)
);
return;
}
e.ErrorContent = string.Format
(
"The discount cannot be greater than 30% (${0}). Please correct the price.",
Convert.ToDouble(e.CellValue) * 0.7
);
}
}
}
#endregion
728x90
반응형
그리드형(광고전용)
댓글을 달아 주세요