Tengo un DataGridView
con varias columnas creadas. He agregado algunas filas y se muestran correctamente; sin embargo, cuando hago clic en una celda, el contenido desaparece.Agregar filas a Datagridview con columnas existentes
¿Qué estoy haciendo mal?
El código es el siguiente:
foreach (SaleItem item in this.Invoice.SaleItems)
{
DataGridViewRow row = new DataGridViewRow();
gridViewParts.Rows.Add(row);
DataGridViewCell cellQuantity = new DataGridViewTextBoxCell();
cellQuantity.Value = item.Quantity;
row.Cells["colQuantity"] = cellQuantity;
DataGridViewCell cellDescription = new DataGridViewTextBoxCell();
cellDescription.Value = item.Part.Description;
row.Cells["colDescription"] = cellDescription;
DataGridViewCell cellCost = new DataGridViewTextBoxCell();
cellCost.Value = item.Price;
row.Cells["colUnitCost1"] = cellCost;
DataGridViewCell cellTotal = new DataGridViewTextBoxCell();
cellTotal.Value = item.Quantity * item.Price;
row.Cells["colTotal"] = cellTotal;
DataGridViewCell cellPartNumber = new DataGridViewTextBoxCell();
cellPartNumber.Value = item.Part.Number;
row.Cells["colPartNumber"] = cellPartNumber;
}
Gracias!
Tengo una publicación aquí eliminé, estaba relacionada con asp.net ya que no hago ninguna programación de winforms y lo tomé como asp.net. perdón por eso en caso de que lo leas y te engañes un poco. – mattlant
Bien, gracias. De todos modos, no lo vi. – Nacho