Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
295
New UltraGrid data being lost when opening a new form
posted

I have an order form open, where the grid is used for adding order lines to the order.

When opening an order that has been created, then adding a new line to it, I'm then opening another form, for adding some of the other details to the order line (I'm not closing the main form, just opening a new one).

However, when the new form opens, the initial data that was saved with the report is removed from the grid, and only the newly added, unsaved data is then shown.

What could be causing this?

The code for opening the new form:

Try
  For Each ugr As UltraGridRow In ugProducts.Rows
   If IsDBNull(ugr.Cells("Supplier_Code").Value) = True Then
    MsgBox("Please select a supplier for all products first", MsgBoxStyle.OkOnly, "Select a Supplier")
    Exit Sub
   End If
  Next

 Dim dt As New DataTable
 dt = ugProducts.DataSource

 Dim f As New frmFreight(con, dt, Me, cmbCustCode.Text, orderNumber)
 f.MdiParent = Me.MdiParent
 f.Show()

Catch ex As Exception
  errorLog(ex)

End Try

 

Parents
No Data
Reply
  • 7695
    Offline posted

    Hi David,

       I am not entirely following issue entirely. You have your Order Form, that opens an Order Detail Form, when you want to add a new detail line on the Order Form. You are adding new data, so I am guessing the Order Detail Form is mostly empty to begin with, but your Order Form likely has some initial information, and perhaps other detail lines.

    Here's where you lose me a bit, when the new form opens:
    I am assuming the Order Detail Form, the initial data that was saved with the report?
    Do you mean the other information on the Order Form is cleared from the Order Form, when the Order Detail Form opens?
    What is the report, is that a different object or are you referring to the Order Form?
    Newly added, unsaved data, I am assuming you mean the data that was filled into the Order Detail Form, when filled out and closed, populates the Order Form, but the previous Order Form detail lines are wiped out?

    My guess is the issue is on your Order Detail Form. There is nothing in your snippet that would cause the issue directly. Just that it identifies that you are passing in references to the DataSource of the Order Form grid, the Order Form itself, and whatever con is. I would likely need a sample application to better understand what is going on. But I would follow those three variables on your Order Detail Form, and see what you are doing with them. Are you re-instantiating dt? Are you calling Clear before you add? Are you accessing sub properties on your form that is passed in? If so what are you modifying.

    Hope this helps,

Children