回复 11楼q406157290的帖子
只需要下面一个事件就可以了,像rowEditEnded,rowEditEnding,selectChangeing,CellEditEnded事件加多了反而会乱;
- private void _flexDei_CellEditEnding(object sender, CellEditEventArgs e)
- {
- try
- {
- foreach (Column column in _flexDei.Columns)
- {
- foreach (Row row in _flexDei.Rows)
- {
- if (!string.IsNullOrEmpty(row.GetErrors(column)))
- {
- // e.Cancel = true;// 注释掉,否则编辑的内容无法应用,该单元格位置的编辑状态始终无法结束
- C1FlexGridFilter filter = C1FlexGridFilterService.GetFlexGridFilter(_flexDei);
- ColumnFilterEditor editor = filter.Editor;
- List<object> values = new List<object>();
- foreach (object obj in editor.Filter.ValueFilter.Values)
- {
- values.Add(obj);
- }
- values.Add(_flexDei[e.Row, e.Column]);
- editor.Filter.ValueFilter.Values = values;
- }
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
复制代码
在对values集合处理时,values.Add(_flexDei[e.Row, e.Column]); 在这之前最好判断此时单元格编辑后的值是否在集合内,再决定是否添加; |