private void fillGrid() { try { //clear the gridview if there are any rows grd_stockCurrent.DataSource = null; grd_stockCurrent.Refresh(); DataGridViewButtonColumn col = new DataGridViewButtonColumn(); col.DataPropertyName = "stockEntryId"; col.Name = "stockEntryId"; col.HeaderText = "Stock Entry Id"; grd_stockCurrent.Columns.Add(col); grd_stockCurrent.DataSource = MANAGEDB.getCurrentDayStockDetails(); grd_stockCurrent.ColumnHeadersDefaultCellStyle.Font = new Font(DataGridView.DefaultFont, FontStyle.Bold); //arrange the gridview grd_stockCurrent.Columns["stockEntryId"].DisplayIndex = 0; grd_stockCurrent.Columns["itemCode"].DisplayIndex = 1; grd_stockCurrent.Columns["itemName"].DisplayIndex = 2; grd_stockCurrent.Columns["quantity"].DisplayIndex = 3; grd_stockCurrent.Columns["symbol"].DisplayIndex = 4; grd_stockCurrent.Columns["remainQuantity"].DisplayIndex = 5; grd_stockCurrent.Columns["buyingUnitPrice"].DisplayIndex = 6; grd_stockCurrent.Columns["totalValue"].DisplayIndex = 7; grd_stockCurrent.Columns["sellingUnitPrice"].DisplayIndex = 8; grd_stockCurrent.Columns["createDate"].DisplayIndex = 9; //grd_stockCurrent.Columns["updateDate"].DisplayIndex = 10; //grd_stockCurrent.Columns["stockEntryDate"].DisplayIndex = 11; //grd_stockCurrent.Columns["expirationDate"].DisplayIndex = 12; grd_stockCurrent.Columns["dealerName"].DisplayIndex = 13; //change the header names grd_stockCurrent.Columns["stockEntryId"].HeaderText = "Stock_Id"; grd_stockCurrent.Columns["itemCode"].HeaderText = "Item_Code"; grd_stockCurrent.Columns["itemName"].HeaderText = "Item_Name"; grd_stockCurrent.Columns["quantity"].HeaderText = "Qty"; grd_stockCurrent.Columns["symbol"].HeaderText = "Symbol"; grd_stockCurrent.Columns["remainQuantity"].HeaderText = "Remain_Qty"; grd_stockCurrent.Columns["buyingUnitPrice"].HeaderText = "Unit_Price(Buy)"; grd_stockCurrent.Columns["totalValue"].HeaderText = "Total"; grd_stockCurrent.Columns["sellingUnitPrice"].HeaderText = "Unit_Price(Sell)"; grd_stockCurrent.Columns["createDate"].HeaderText = "Create"; grd_stockCurrent.Columns["updateDate"].HeaderText = "Update"; grd_stockCurrent.Columns["stockEntryDate"].HeaderText = "Entry"; grd_stockCurrent.Columns["expirationDate"].HeaderText = "Expire"; grd_stockCurrent.Columns["dealerName"].HeaderText = "Dealer"; //hide columns grd_stockCurrent.Columns["updateDate"].Visible = false; grd_stockCurrent.Columns["stockEntryDate"].Visible = false; grd_stockCurrent.Columns["expirationDate"].Visible = false; grd_stockCurrent.Columns["itemId"].Visible = false; grd_stockCurrent.Columns["priceAfterDiscount"].Visible = false; grd_stockCurrent.Columns["comment"].Visible = false; grd_stockCurrent.Columns["releaseFlg"].Visible = false; grd_stockCurrent.Columns["dealerId"].Visible = false; grd_stockCurrent.Columns["stockUnitId"].Visible = false; } catch (Exception ex) { COM_MESSAGE.exceptionMessage(ex.Message); } }