public static void RemoveDynamicColumns(ColumnView gridView, IDynamicPropertyList propertyList) { gridView.BeginDataUpdate(); foreach (IDynamicProperty p in propertyList.GetProperties(true)) { GridColumn foundColumn = null; foreach (GridColumn column in gridView.Columns) { if (column.Tag != null) { var keyValue = column.Tag as string; if (keyValue != null) { if (keyValue == p.Key) { foundColumn = column; } } } } if (foundColumn != null) { gridView.Columns.Remove(foundColumn); foundColumn.Dispose(); } } gridView.EndDataUpdate(); }
public static string ConvertToString <T>(IDynamicPropertyList propertyList) { string valueString = string.Empty; if (propertyList != null) { foreach (IDynamicProperty p in propertyList.GetProperties(false)) { valueString += p.DisplayName.ToString() + "=" + p.Value.ToString() + "; "; } } return(valueString); }
public static void RemoveDynamicBandsAndColumns(GridBand onThisBand, IDynamicPropertyList headerList) { if (onThisBand.View == null) { return; } onThisBand.View.BeginDataUpdate(); foreach (IDynamicProperty header in headerList.GetProperties(true)) { BandedGridColumn foundColumn = null; foreach (GridBand childBand in onThisBand.Children) { foreach (BandedGridColumn column in childBand.Columns) { if (column.Tag != null) { var keyValue = column.Tag as string; if (keyValue != null && keyValue == header.Key) { foundColumn = column; break; } } } if (foundColumn != null) { childBand.Columns.Remove(foundColumn); foundColumn.Dispose(); break; } } // Jetzt noch die Nutzlosen Bänder entfernen. // Das machen wir mit der üblichen EntfernungsTaktik: Von hinten nach vorne, damit wir uns nicht den Boden unter den Füssen wegziehen. // (Foreach geht sowieso nicht) for (int i = onThisBand.Children.Count - 1; i >= 0; i--) { if (onThisBand.Children[i].Columns.Count == 0) { onThisBand.Children.Remove(onThisBand.Children[i]); } } } onThisBand.View.EndDataUpdate(); }
private static void AddDynamicColumns(GridView gridView, IDynamicPropertyList propertyList, bool addFilter) { gridView.BeginDataUpdate(); int visibleIndexValue = 0; foreach (GridColumn column in gridView.Columns) { if (column.VisibleIndex > visibleIndexValue) { visibleIndexValue = column.VisibleIndex; } } foreach (IDynamicProperty property in propertyList.GetProperties(true)) { var newColumn = new GridColumn(); newColumn.Caption = property.DisplayName; newColumn.FieldName = property.Key; newColumn.Name = "col" + property.Key; newColumn.OptionsColumn.ReadOnly = property.ReadOnly; newColumn.Visible = property.Visible; newColumn.ToolTip = property.Description; newColumn.OptionsFilter.AllowFilter = addFilter; if (property.Visible) { visibleIndexValue++; newColumn.VisibleIndex = visibleIndexValue; } else { newColumn.VisibleIndex = -1; } newColumn.Tag = property.Key; newColumn.UnboundType = GetUnboundType(property); //check if column exists foreach (GridColumn column in gridView.Columns) { Debug.Assert(column.Name != newColumn.Name, "Column with this name exists already"); } gridView.Columns.Add(newColumn); } gridView.EndDataUpdate(); }
public static void RemoveDynamicColumns(GridBand onThisBand, IDynamicPropertyList propertyList) { if (onThisBand.View == null) { return; } onThisBand.View.BeginDataUpdate(); foreach (IDynamicProperty p in propertyList.GetProperties(true)) { BandedGridColumn foundColumn = null; foreach (BandedGridColumn column in onThisBand.Columns) { if (column.Tag != null) { var keyValue = column.Tag as string; if (keyValue != null) { if (keyValue == p.Key) { foundColumn = column; } } } } if (foundColumn != null) { onThisBand.Columns.Remove(foundColumn); foundColumn.Dispose(); } } onThisBand.View.EndDataUpdate(); }