private void UpdateTreeModel() { var firstInit = MaintainerPersonalSettings.References.referencesTreeHeaderState == null || MaintainerPersonalSettings.References.referencesTreeHeaderState.columns == null || MaintainerPersonalSettings.References.referencesTreeHeaderState.columns.Length == 0; var headerState = ReferencesTreeView <ReferencesTreeElement> .CreateDefaultMultiColumnHeaderState(); if (MultiColumnHeaderState.CanOverwriteSerializedFields(MaintainerPersonalSettings.References.referencesTreeHeaderState, headerState)) { MultiColumnHeaderState.OverwriteSerializedFields(MaintainerPersonalSettings.References.referencesTreeHeaderState, headerState); } MaintainerPersonalSettings.References.referencesTreeHeaderState = headerState; var multiColumnHeader = new MaintainerMultiColumnHeader(headerState); if (firstInit) { MaintainerPersonalSettings.References.referencesTreeViewState = new TreeViewState(); } treeElements = LoadLastTreeElements(); treeModel = new TreeModel <ReferencesTreeElement>(treeElements); treeView = new ReferencesTreeView <ReferencesTreeElement>(MaintainerPersonalSettings.References.referencesTreeViewState, multiColumnHeader, treeModel); treeView.SetSearchString(MaintainerPersonalSettings.References.searchString); treeView.Reload(); searchField = new SearchField(); searchField.downOrUpArrowKeyPressed += treeView.SetFocusAndEnsureSelectedItem; if (firstInit) { multiColumnHeader.ResizeToFit(); } }