private void m_searchTextBox_TextChanged(object sender, EventArgs e)
        {
            try
            {
                var sortedColumn = m_dataGridView.SortedColumn;
                var sortOrder    = m_dataGridView.SortOrder;

                m_dataGridView.SuspendLayout();
                m_dataGridView.Rows.Clear();

                foreach (var vm in Connection.Cache.VMs.Where(IsVmExportable))
                {
                    if (MatchesSearchText(vm))
                    {
                        m_dataGridView.Rows.Add(GetDataGridViewRow(vm, VMsToExport.Contains(vm)));
                    }
                }

                if (sortOrder != SortOrder.None && sortedColumn != null)
                {
                    m_dataGridView.Sort(sortedColumn, (sortOrder == SortOrder.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending);
                }
            }
            finally
            {
                m_dataGridView.ResumeLayout();
            }
        }
        private void m_dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex != 0 || e.RowIndex < 0 || e.RowIndex >= m_dataGridView.RowCount)
            {
                return;
            }

            var row = m_dataGridView.Rows[e.RowIndex];
            var vm  = row.Tag as VM;

            if (vm != null)
            {
                if ((bool)row.Cells[0].Value)
                {
                    if (!VMsToExport.Contains(vm))
                    {
                        VMsToExport.Add(vm);
                    }
                }
                else
                {
                    VMsToExport.Remove(vm);
                }
            }

            m_ctrlError.HideError();
            UpdateCounterLabel();
            IsDirty = true;
            EnableButtons();
        }
Beispiel #3
0
        private void m_buttonSelectAll_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow dataGridViewRow in m_dataGridView.Rows)
            {
                dataGridViewRow.Cells[0].Value = true;

                if (dataGridViewRow.Tag is VM vm && !VMsToExport.Contains(vm))
                {
                    VMsToExport.Add(vm);
                }
            }
        }