private void ActExtract_Click(System.Object sender, System.EventArgs e) { // ----- Create a new table based on the original. DataView interimView; DataTable generatedTable = null; // ----- At least one column is required. if (IncludedColumns.CheckedItems.Count == 0) { MessageBox.Show("Please include at least one column."); IncludedColumns.Focus(); return; } // ----- Clear the previous results. NewRecords.DataSource = null; // ----- Build a view that will generate the new table. interimView = new DataView(SampleData); // ----- Apply the optional filter. try { if (FilterExpression.Text.Trim().Length > 0) { interimView.RowFilter = FilterExpression.Text.Trim(); } } catch (Exception ex) { MessageBox.Show("Could not apply the filter: " + ex.Message); return; } // ----- Generate the new table. try { generatedTable = interimView.ToTable(true, IncludedColumns.CheckedItems.Cast <string>().ToArray()); } catch (Exception ex) { MessageBox.Show("Could not build the new table: " + ex.Message); return; } // ----- Display the results. NewRecords.DataSource = generatedTable; }
private void ActExtract_Click(System.Object sender, System.EventArgs e) { // ----- Create a new table based on the original. DataView interimView; DataTable generatedTable = null; // ----- At least one column is required. if (IncludedColumns.CheckedItems.Count == 0) { MessageBox.Show("Please include at least one column."); IncludedColumns.Focus(); return; } // ----- Clear the previous results. NewRecords.DataSource = null; // ----- Build a view that will generate the new table. // ----- Apply the optional filter. try { } catch (Exception ex) { MessageBox.Show("Could not apply the filter: " + ex.Message); return; } // ----- Generate the new table. try { } catch (Exception ex) { MessageBox.Show("Could not build the new table: " + ex.Message); return; } // ----- Display the results. NewRecords.DataSource = generatedTable; }