public override void PopulatePage() { var pool = Helpers.GetPoolOfOne(Connection); label2.Text = string.Format(Helpers.IsPool(pool.Connection) ? Messages.VMS_IN_POOL : Messages.VMS_IN_SERVER, pool.Name.Ellipsise(60)); VMsToExport.Clear(); try { m_dataGridView.SuspendLayout(); m_dataGridView.Rows.Clear(); var applianceVMs = new List <XenRef <VM> >(); if (SelectedItems != null && SelectedItems.FirstIs <VM_appliance>()) { applianceVMs.AddRange(((VM_appliance)SelectedItems.FirstAsXenObject).VMs); } foreach (var vm in Connection.Cache.VMs.Where(vm => IsVmExportable(vm) && MatchesSearchText(vm))) { VM curVm = vm; //closure below bool selected = SelectedItems != null && (SelectedItems.AsXenObjects().Contains(vm) || applianceVMs.FirstOrDefault(xenref => xenref.opaque_ref == curVm.opaque_ref) != null); m_dataGridView.Rows.Add(GetDataGridViewRow(vm, selected)); if (selected) { VMsToExport.Add(vm); } } m_dataGridView.Sort(columnTick, ListSortDirection.Descending); } finally { m_dataGridView.ResumeLayout(); } UpdateCounterLabel(); EnableButtons(); }