개발/C# + DevExpress
[2021.10] XtraGrid 특정 Row의 컬럼 값 편집 여부를 설정하는 방법
다물칸
2021. 10. 22. 15:08
728x90
반응형
안녕하세요. 오랜만에 올립니다.
엑셀처럼 편집이 가능한 그리드를 구현하고자 하는데 특정 Row의 특정 컬럼만 에디트를 가능하게 하거나 혹은 불가능하게 할 경우 아래 "ShowingEditor"이벤트에서 구현하시면 됩니다.
private bool USCanada(GridView view, int row) {
GridColumn col = view.Columns["Country"];
string val = Convert.ToString(view.GetRowCellValue(row, col));
return (val == "USA" || val == "Canada");
}
// disable editing
private void gridView1_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e) {
GridView view = sender as GridView;
if(view.FocusedColumn.FieldName == "Region" && !USCanada(view, view.FocusedRowHandle))
e.Cancel = true;
}
반응형