private void InsertRow(Vdine.PosApp.UI.Models.OrderModule.OrderManagementModel orderManagementModel, bool isInsertToTop) { DataGridViewRow row = new DataGridViewRow(); row.Height = 40; row.DefaultCellStyle.SelectionForeColor = Color.Black; DataGridViewCell cellFoodName = new DataGridViewTextBoxCell(); cellFoodName.Value = orderManagementModel.FoodName; row.Cells.Add(cellFoodName); if (orderManagementModel.OrderDetail != null) { DataGridViewCell cellQty = new DataGridViewTextBoxCell(); cellQty.Value = orderManagementModel.OrderDetail.Quantity; row.Cells.Add(cellQty); FoodCoursingUserControl foodCoursingUserControl = new FoodCoursingUserControl(); foodCoursingUserControl.Visible = true; CustomeCell customCell = new CustomeCell(); customCell.Value = foodCoursingUserControl; DataGridViewCell cellOrderCoursingId = customCell; //// new DataGridViewTextBoxCell(); cellOrderCoursingId.Value = customCell.Value; row.Cells.Add(cellOrderCoursingId); DataGridViewCell cellOrderDetailId = new DataGridViewTextBoxCell(); cellOrderDetailId.Value = orderManagementModel.OrderDetail.OrderDetailID; row.Cells.Add(cellOrderDetailId); } else { cellFoodName.Style.Font = new Font(this.orderdetailsDataGridView.DefaultCellStyle.Font, FontStyle.Bold); row.DefaultCellStyle.BackColor = Color.Orange; DataGridViewCell cellQty = new DataGridViewTextBoxCell(); cellQty.Value = string.Empty; row.Cells.Add(cellQty); FoodCoursingUserControl foodCoursingUserControl = new FoodCoursingUserControl(); foodCoursingUserControl.Visible = true; CustomeCell customCell = new CustomeCell(); customCell.Value = foodCoursingUserControl; DataGridViewCell cellOrderCoursingId = customCell; ////new DataGridViewTextBoxCell(); cellOrderCoursingId.Value = customCell.Value; row.Cells.Add(cellOrderCoursingId); DataGridViewCell cellOrderDetailId = new DataGridViewTextBoxCell(); cellOrderDetailId.Value = string.Empty; row.Cells.Add(cellOrderDetailId); } this.orderdetailsDataGridView.Rows.Insert(isInsertToTop ? 0 : this.orderdetailsDataGridView.Rows.Count, row); }
/// <summary> /// Handles the CellClick event of the OrderdetailsDataGridView control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.DataGridViewCellEventArgs"/> instance containing the event data.</param> private void OrderdetailsDataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { string commandName = this.orderdetailsDataGridView.Columns[e.ColumnIndex].HeaderText; string orderDetailId = this.orderdetailsDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString(); FoodCoursingUserControl cntrl = this.orderdetailsDataGridView.Rows[e.RowIndex].Cells[2].Value as FoodCoursingUserControl; if (string.IsNullOrEmpty(orderDetailId)) { if (commandName == "Order Coursing") { } } else { DataGridViewCell coursingCell = (DataGridViewCell)this.orderdetailsDataGridView.Rows[e.RowIndex].Cells[2]; if (commandName == "Order Coursing") { string selectedId = (string)cntrl.Tag; } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)