반응형
그리드 내의 컬럼마다 계산식 등등이 있을때, 해당 식 적용 방법.
경우의 수
1.row 변경
2.동일 row 내에서 focuscolumn 변경
3.외부 컨트롤로 focus이동
//값 변경시 advBandedGridView.KeyDown += AdvBandedGridView_KeyDown; //row의 focus column이 변경되었을 시 advBandedGridView.FocusedColumnChanged += AdvBandedGridView_FocusedColumnChanged; //grid내에서 row변경시 advBandedGridView.BeforeLeaveRow += AdvBandedGridView_BeforeLeaveRow; //grid의 focus를 잃었을 때 advBandedGridView.LostFocus += AdvBandedGridView_LostFocus; private void AdvBandedGridView_KeyDown(object sender, KeyEventArgs e) { if (advBandedGridView.GetFocusedDataRow() != null) qtyCalc(advBandedGridView.GetFocusedDataRow()); } private void AdvBandedGridView_FocusedColumnChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedColumnChangedEventArgs e) { if (advBandedGridView.GetFocusedDataRow() != null) qtyCalc(advBandedGridViewStoreList.GetFocusedDataRow()); } private void AdvBandedGrid_BeforeLeaveRow(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e) { if (advBandedGridView.GetFocusedDataRow() != null) qtyCalc(advBandedGridViewStoreList.GetFocusedDataRow()); } private void AdvBandedGridView_LostFocus(object sender, EventArgs e) { float UNIT_CNT = 0; float QN_UNIT = 0; float QN_EA = 0; float QN = 0; DataRow dr = advBandedGridViewStoreList.GetFocusedDataRow(); DevExpress.XtraGrid.Views.Base.ColumnView view = (DevExpress.XtraGrid.Views.Base.ColumnView)sender; if (advBandedGridViewList.GetFocusedDataRow() == null || dr == null) return; DevExpress.XtraEditors.TextEdit editor = (DevExpress.XtraEditors.TextEdit)view.ActiveEditor; if (view.FocusedColumn.FieldName.Equals("QN_UNIT"))//column search { if (!float.TryParse(editor.EditValue.ToString(), out QN_UNIT)) QN_UNIT = 0; if (!float.TryParse(dr["QN_EA"].ToString(), out QN_EA)) QN_EA = 0; } else { if (!float.TryParse(dr["QN_UNIT"].ToString(), out QN_UNIT)) QN_UNIT = 0; if (!float.TryParse(editor.EditValue.ToString(), out QN_EA)) QN_EA = 0; } if (!float.TryParse(advBandedGridViewList.GetFocusedDataRow()["UNIT_CNT"].ToString(), out UNIT_CNT)) UNIT_CNT = 0; QN = (UNIT_CNT * QN_UNIT) + QN_EA; dr["QN"] = QN.ToString(); }
반응형
'Winform' 카테고리의 다른 글
[DevExpress] 그리드의 체크박스 한개만 선택 할때 (0) | 2019.01.23 |
---|---|
[DevExpress] TextEdit에 Invalid Value 아이콘 제거 하기. (4) | 2019.01.22 |
DevExpress PictureEdit Drag&Drop (4) | 2018.03.13 |
크로스 스레드 (2) | 2017.03.22 |
화면 깜빡임 처리 (0) | 2016.08.05 |
댓글