Note that there are some explanatory texts on larger screens.

plurals
  1. POrow is not adding to datagridview automatically
    primarykey
    data
    text
    <p>In my datagridview, AllowUserToAddRow = true; When I start editing a cell, a new blank row is automatically added at the end and that is absolutely fine. But if I try to populate the whole row programmatically (e.g. say you click on a button that opens a child form, the child form when closed sends data to parent form that contains the datagridview and there you bind all data to the datagridview row) in that case a new blank row is not added automatically. If I start editing any cell data it results in the appearance of the desired blank row. What can be the problem?</p> <h2>I think many of you have come across this problem earlier. Any one successfully addressed it? Please provide the soln.</h2> <p>Edit: Sample code attached</p> <pre><code>//Uses Linq-to-Entities IQueryable&lt;Product&gt; productQuery = from prod in sampleTaskContext.Product where prod.ProductId == enteredProdId select prod; List&lt;Product&gt; foundProd = productQuery.ToList(); if (foundProd.Count &lt;= 0) { ProductsForm prodForm = new ProductsForm(); prodForm.ShowInTaskbar = false; if (prodForm.ShowDialog() == DialogResult.OK) { Product returnedProd = prodForm.fnFormatProductDataForOrder(); foundProd.Add(returnedProd); } } if (foundProd.Count &gt; 0) { int selectedRowIndex = this.dgvOrderEntryDetails.SelectedCells[0].RowIndex; dgvOrderEntryDetails.Rows[selectedRowIndex].Cells["colProdId"].Value = foundProd[0].ProductId; dgvOrderEntryDetails.Rows[selectedRowIndex].Cells["colDesc"].Value = foundProd[0].ItemDescription.ToString(); dgvOrderEntryDetails.Rows[selectedRowIndex].Cells["colQty"].Value = 1; dgvOrderEntryDetails.Rows[selectedRowIndex].Cells["colListPrice"].Value = foundProd[0].SalesPrice; dgvOrderEntryDetails.Rows[selectedRowIndex].Cells["colDisc"].Value = 0; dgvOrderEntryDetails.Rows[selectedRowIndex].Cells["colPrice"].Value = foundProd[0].SalesPrice; dgvOrderEntryDetails.Rows[selectedRowIndex].Cells["colTotal"].Value = foundProd[0].SalesPrice; </code></pre> <h2> }</h2> <p>Edit: <img src="https://i.stack.imgur.com/jYvNC.jpg" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload