public PQ_MainScreen() { InitializeComponent(); sql = new MySQLDatabaseDriver(); pqList = new ArrayList(); //---ADJUST DATAGRIDVIEW COLUMN ALIGNMENT //Center column header dgvPQ.Columns["Date"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvPQ.Columns["PQNumber"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; //Center column contents dgvPQ.Columns["Date"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvPQ.Columns["PQNumber"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; //---TEST CODE (For the purpose of customizing the DGV and checking out its appearance) /*dgvPQ.Rows.Add("11/20/2015", "ABC Company", "ATPI 1611-016", "01/01/2015 - 11/05/2017"); * dgvPQ.Rows.Add("06/10/2015", "Zen Nutrients Co.", "ATPI 1606-005", "02/01/2015 - 12/03/2017"); * dgvPQ.Rows.Add("09/07/2015", "Coletteās Company", "ATPI 1609-048", "03/01/2015 - 09/05/2017"); * dgvPQ.Rows.Add("07/12/2015", "Joy Luck Club", "ATPI 1607-004", "04/01/2015 - 08/02/2017");*/ sql.SelectAllPQDGV(dgvPQ); dgvPQ.Sort(dgvPQ.Columns["PQNumber"], ListSortDirection.Descending); //Sort datagridview by LATEST PQ Number (Note: When you add a PQ, it should appear at the top of the DGV) sql.SelectAllPQ(pqList); }
private void btnClearSearch_Click(object sender, EventArgs e) { //Minor flaw: If you click ClearSearch multiple times, the dgv gets populated again, even though nothing was searched. Hehe. dgvPQ.Rows.Clear(); sql.SelectAllPQDGV(dgvPQ); //Populate DGV //Sort datagridview by LATEST PO Number dgvPQ.Sort(dgvPQ.Columns["PQNumber"], ListSortDirection.Descending); txtSearch.Text = "Search for..."; cbbFilterBy.SelectedIndex = 0; //Sets the combobox value to "Filter by..." }