private void SetCollumns() { if (VisbleColumns.Count == 0) { ViewResult.FormatGrid(Query.Fields, ColumnsParameters); } else { var columns = Query.Fields.Where(p => VisbleColumns.Any(v => v == p.Name)); var col = new TableAdapterFieldCollection(); col.AddRange(columns); ViewResult.FormatGrid(col); } ViewResult.FocusedColumn = SearchColumns.IsEmpty() ? ViewResult.Columns[0] : ViewResult.Columns[SearchColumns.First().Name]; ViewResult.SetColors(); ViewResult.FormatConditions.Clear(); foreach (var item in Conditions) { var col = ViewResult.Columns[item.ColumnName]; if (col == null) { continue; } var scon = new DevExpress.XtraGrid.StyleFormatCondition( item.FormatConditionEnum, col, null, item.val1, item.val2, item.applyToRow); scon.Appearance.BackColor = item.BackColor; scon.Appearance.ForeColor = item.ForeColor; ViewResult.FormatConditions.Add(scon); } }