private void frmAllBillForSupplier_Load(object sender, EventArgs e) { ExtensionMethods.FormLoad(this, "LIST OF PURCHASE INVOICES"); List <PharmaBusinessObjects.Transaction.ReceiptPayment.BillOutstanding> list = applicationFacade.GetAllPurchaseInvoiceForSuppier(SupplierCode, Date); if (list == null) { list = new List <PharmaBusinessObjects.Transaction.ReceiptPayment.BillOutstanding>(); } dgvPurchaseBill.DataSource = list.OrderByDescending(p => p.VoucherDate).ToList(); ExtensionMethods.SetGridDefaultProperty(dgvPurchaseBill); dgvPurchaseBill.Columns["PurchaseSaleBookHeaderID"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvPurchaseBill.Columns["PurchaseSaleBookHeaderID"].Visible = true; dgvPurchaseBill.Columns["PurchaseSaleBookHeaderID"].HeaderText = "PurchaseSaleBookHeaderID"; dgvPurchaseBill.Columns["InvoiceNumber"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvPurchaseBill.Columns["InvoiceNumber"].Visible = true; dgvPurchaseBill.Columns["InvoiceNumber"].HeaderText = "Purchase Bill No."; dgvPurchaseBill.Columns["VoucherDate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvPurchaseBill.Columns["VoucherDate"].Visible = true; dgvPurchaseBill.Columns["VoucherDate"].HeaderText = "Bill Date"; dgvPurchaseBill.Columns["BillAmount"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvPurchaseBill.Columns["BillAmount"].Visible = true; dgvPurchaseBill.Columns["BillAmount"].HeaderText = "Bill Amount"; if (dgvPurchaseBill.Rows.Count > 0) { dgvPurchaseBill.Rows[0].Selected = true; } dgvPurchaseBill.KeyDown += DgvPurchaseBill_KeyDown; this.FormClosing += FrmAllBillForSupplier_FormClosing; }