Mam DataGridView
z kilkoma utworzonymi kolumnami. Dodałem kilka wierszy i wyświetlają się poprawnie; jednak po kliknięciu komórki zawartość znika.Dodawanie wierszy do datagridview z istniejącymi kolumnami
Co robię źle?
Kod jest w następujący sposób:
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;
}
Dzięki!
Mam post na tutaj usunięty, był w stosunku do asp.net, ponieważ nie robię żadnego programowania WinForms i pomyliłem to jako asp.net. Przepraszam za to na wypadek, gdybyś go przeczytał i trochę ci to zmylił. – mattlant
Ok dzięki, w każdym razie nie widziałem. – Nacho