I have been trying to figure this out for the past day or so and need some help. I am passing data from a combobox in one form to a combobox in a second form.
The first time I click on the "cmdNewTicket", everything shows up just fine in the new form EXCEPT the data in the combobox.
The second time I click on the "cmdNewTicket" cmd button, everything works exactly as it should...even the combobox.
Here's the code:
VB Code:
Private Sub cmdNewTicket_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNewTicket.Click Dim newTicketForm As frmCreateRemainderRawTickets 'This call instantiates the forms collection to the form that I am creating. 'The second time I run this, the initialization portion is not called 'from the form manager. newTicketForm = CType(FormManager.getForm(FormManager.CREATE_REMAINDER_RAW_TICKETS), frmCreateRemainderRawTickets) Dim drv As DataRowView drv = cmbTicketNum.SelectedItem 'I think that this is what is happening. 'When run for the first time, 'The selected item, cmbTicketNum.selecteditem, is the first record because the 'Recordset is re-initialized during the call to the 'Form Manager above. Dim row As Data.DataRow row = drv.Row Dim origCourses As Decimal = CDec(lblCourses.Text) Dim usedCourses As Decimal = CDec(txtNumberOfCourses.Text) Dim defaultCourses = origCourses - usedCourses 'Get the width and length to transfer over to other form Dim nWidth As Decimal = CDec(lblWidth.Text) Dim nLength As Decimal = CDec(lblLength.Text) newTicketForm.prime2(tempRemainderTickets, row("PK_Item"), row("sDescription"), defaultCourses, nWidth, nLength, Me) End Sub
VB Code:
'Second Form Public Sub prime2(ByVal inTickets As ArrayList, _ ByVal inItemPk As Integer, _ ByVal itemDesc As String, _ ByVal defaultCourses As Decimal, _ ByVal width As Decimal, _ ByVal length As Decimal, _ ByVal inCallingForm As frmConsumeRawMaterial) autoUpdate = True callingForm = inCallingForm tickets = inTickets itemPk = inItemPk ' Suppress repainting the TreeView until all the objects have been created. TreeView1.BeginUpdate() ' Clear the TreeView each time the method is called. TreeView1.Nodes.Clear() If tickets.Count > 0 Then Dim ticket As RawTicket For Each ticket In tickets Dim node As TreeNode node = New TreeNode("Ticket #" & ticket.getTicketNum()) TreeView1.Nodes.Add(node) Next End If 'lblItemDesc.Text = itemDesc clearFields() cboItem.SelectedValue = itemPk txtNumberofCourses.Text = defaultCourses txtAverageWidth.Text = width txtAverageLength.Text = length ' Look up item PK, width, length, and thickness if haven't already. 'If poItem.getItemPK < 0 Then ' setItemInfo() 'End If ' Begin repainting the TreeView. TreeView1.EndUpdate() autoUpdate = False dataValidator = New DataValidator 'callingForm.Hide() Me.Show() End Sub Public Overrides Sub init() 'This is where the passed data to the combobox it cleared when the 'Consume Raw Material form attempts to pass the selected item to the 'Create Remainder Raw Material Tickets form. This event only happens 'the first time which is consistant with the reason the data is there 'the first time but not following times. DataSetRemainderItem1.Clear() ItemsDataAdapter1.Fill(DataSetRemainderItem1) End Sub




Reply With Quote