When I hit the submit button I want the entered data to appear in textboxes on groupForm, but this isn’t happening. I have to restart the form or hit the Refresh button for the data to appear.

UPDATE
I zoned in on the problem;
I have to pass arguments to the form so it knows which groups’ data to show, like this;
Dim frmReceiver As New form_addNewProfitObject
frmReceiver.setGroup(theMainGroupID, theGroupID)
frmReceiver.ShowDialog()
If I open the form like this, the data entered appears just fine without refreshing;
form_addNewProfitObject.Show()
But this way the form wouldn’t know what group to add data to. Is there a work around? I also tried to do frmReceiver.Show() instead of frmReceiver.ShowDialog() but that doesn’t make a difference.
I’m not entirely sure why the method I am using isn’t working.. maybe it’s because upon hitting ‘submit’ it calls groupForm.NewProfitObjectsItem(ByVal *snip*) and this doesn’t work if groupForm was created using new ?
END UPDATE
Here’s the code for hitting the ‘refresh’ button on Form number one (groupForm.vb).
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
populate(Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID))
End Sub
And here’s the code for the Submit button, which (at the end) calls that exact same function, but from form_addNewProfitObject.vb.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim groupID As Integer = theGroupID
'New ProfitObject
ReDim Preserve Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects.Length)
Dim ProfitObjectID As Integer = Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects.Length - 2
Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID) = New ProfitObject
'Set ProfitObject properties
'Set ID
Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).id = ProfitObjectID
'Set Name
Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).name = TextBox1.Text
'Set Profit
Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).profit = TextBox2.Text
'Set TypeID
Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).typeID = TextBox3.Text
'Set Rarityd
Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).rarity = TextBox4.Text
'populate(Form1.main.Groups(groupID))
Dim textt As String = "ID" & ProfitObjectID.ToString
groupForm.NewProfitObjectsItem(textt, Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).name, Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).profit, Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).rarity, Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).typeID)
groupForm.populate(Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID))
Catch ex As Exception
MsgBox(ex.Message)
End Try
groupForm.Refresh()
Me.Close()
End Sub
I added groupForm.populate() at the end of the latter function for testing purposes, but I know that shouldn’t be necessary (“populate” just loops over all items in the ProfitObjects array and calls NewProfitObjectsItem for each one).
Anyway; when I submit the data from the second form, the groupForm doesn’t automatically show the new data. I either have to hit the refresh button or restart the form (it calls populate() on form load).
I simply want the new item to appear immediately after Submitting it. And it should, because that’s what groupForm.NewProfitObjectsItem() does. And to top it off I added groupForm.populate(). I’m assuming it’s not working because it’s called from an external form, or because the other form is open/has the focus.. Any ideas?
Figured out what was causing it. Since I was using
Newto create & show “groupForm“, “form_addNewProfitObject” wasn’t adding controls to the correct form when it calledgroupForm.NewProfitObjectsItem.I had to move the
Public frmReceiver As New groupForminto theCGroupMainclass so thatform_addNewProfitObjectcan access it like this;Form1.main.Groups(theMainGroupID).frmReceiver.NewProfitObjectsItemThe controls are now correctly added to the
groupFormupon hittingsubmit.