■ UltraGrid 클래스의 BeforeExitEditMode 이벤트를 사용하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
using System.Windows.Forms; using Infragistics.Win.UltraWinGrid; private UltraGrid ultraGrid; private Label errorLabel; ... #region UltraGrid 편집 모드 이탈 전 처리하기 - ultraGrid_BeforeExitEditMode(sender, e) /// <summary> /// UltraGrid 편집 모드 이탈 전 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void ultraGrid_BeforeExitEditMode(object sender, BeforeExitEditModeEventArgs e) { if(this.ultraGrid.ActiveCell == null) { return; } if(this.ultraGrid.ActiveCell.Column.Key != "Bonus") { return; } if(this.ultraGrid.ActiveCell.Text == null || (this.ultraGrid.ActiveCell.Text == string.Empty)) { return; } int currentValue = int.Parse(this.ultraGrid.ActiveCell.Text); int baseValue = (int)this.ultraGrid.ActiveCell.Row.Cells["BaseValue"].Value; if(currentValue < baseValue) { this.errorLabel.Text = "Current Value cannot be less than Base Value"; e.Cancel = true; } } #endregion |