public void addNewProductRecord() { ProductRecord record = ProductDatabase.GetNewestProduct(); tlpDataRecords.Controls.Add(new Label() { Text = record.ProductID.ToString() }, 0, rowIndex); tlpDataRecords.Controls.Add(new Label() { Text = record.Name }, 1, rowIndex); tlpDataRecords.Controls.Add(new Label() { Text = record.Description }, 2, rowIndex); tlpDataRecords.Controls.Add(new Label() { Text = "$" + record.Price.ToString() }, 3, rowIndex); tlpDataRecords.Controls.Add(new Label() { Text = record.Category }, 4, rowIndex); rowIndex++; }
/// <summary> /// This method is responsible for adding the a new ProductRecord to the table. /// It does this by looking for the most recently added ProductRecord in the databse. /// </summary> /// <param name="table">A Table Layout Panel you want to add a new record to.</param> /// <param name="rowIndex">The row index where you want to add the new record.</param> static public void addNewProductRecord(TableLayoutPanel table, int rowIndex) { // Getting the new Product Record ProductRecord record = ProductDatabase.GetNewestProduct(); // Creates a new row in the table and updates the text in the cells table.Controls.Add(new Label() { Text = record.ProductID.ToString() }, 0, rowIndex); table.Controls.Add(new Label() { Text = record.Name }, 1, rowIndex); table.Controls.Add(new Label() { Text = record.Description }, 2, rowIndex); table.Controls.Add(new Label() { Text = "$" + record.Price.ToString() }, 3, rowIndex); table.Controls.Add(new Label() { Text = record.Category }, 4, rowIndex); }