public ChangeToFilteredColumns ( View view ) : void | ||
view | View | |
return | void |
/// <summary> /// The user has pressed OK. Do what's requied. /// </summary> /// <param name="olv"></param> /// <param name="view"></param> protected void Apply(ObjectListView olv, View view) { olv.Freeze(); // Update the column definitions to reflect whether they have been hidden if (view == View.Details) { foreach (OLVColumn col in olv.AllColumns) { col.IsVisible = this.MapColumnToVisible[col]; } } else { foreach (OLVColumn col in olv.AllColumns) { col.IsTileViewColumn = this.MapColumnToVisible[col]; } } // Collect the columns are still visible List <OLVColumn> visibleColumns = this.RearrangableColumns.FindAll( delegate(OLVColumn x) { return(this.MapColumnToVisible[x]); }); // Detail view and Tile view have to be handled in different ways. if (view == View.Details) { // Of the still visible columns, change DisplayIndex to reflect their position in the rearranged list olv.ChangeToFilteredColumns(view); foreach (OLVColumn col in visibleColumns) { col.DisplayIndex = visibleColumns.IndexOf((OLVColumn)col); col.LastDisplayIndex = col.DisplayIndex; } } else { // In Tile view, DisplayOrder does nothing. So to change the display order, we have to change the // order of the columns in the Columns property. // Remember, the primary column is special and has to remain first! OLVColumn primaryColumn = this.AllColumns[0]; visibleColumns.Remove(primaryColumn); olv.Columns.Clear(); olv.Columns.Add(primaryColumn); olv.Columns.AddRange(visibleColumns.ToArray()); olv.CalculateReasonableTileSize(); } olv.Unfreeze(); }