mikerob283
Member
- Joined
- Feb 15, 2005
- Messages
- 12
- Programming Experience
- Beginner
executing events on form 1 from form 2
Pay close attention to comments please. There are alot of things that would be benificial if I could execute events from satellite forms.
Basically this is the real deal I have a datagrid and some labels on form 1.
I click a button on form 1 to open form 2 which has a few search options to help refresh the datagrid with different queries. After choosing a certain company or user on form 2 I need to be able to click apply (executes datagrid's refresh with new query string and keeps form 2 open) or ok (does same as apply but closes form 2 also)
Problem: the lblStatus on form 1 does not have the change I sent to it from form 2's button_click(). That would be because form 1 has to "refresh"? how would I do that? This is the only thing I'm stuck on
below is a short example of what is going on.
Thanks,
Michael
I have searched on this but one article I went to wouldn't refresh the new labels on form 1 and form 1 is the main form so if it closes the whole program closes... that's why I have it initially open visible=false and load up a frmlogin.showdialog()
Pay close attention to comments please. There are alot of things that would be benificial if I could execute events from satellite forms.
Basically this is the real deal I have a datagrid and some labels on form 1.
I click a button on form 1 to open form 2 which has a few search options to help refresh the datagrid with different queries. After choosing a certain company or user on form 2 I need to be able to click apply (executes datagrid's refresh with new query string and keeps form 2 open) or ok (does same as apply but closes form 2 also)
Problem: the lblStatus on form 1 does not have the change I sent to it from form 2's button_click(). That would be because form 1 has to "refresh"? how would I do that? This is the only thing I'm stuck on
below is a short example of what is going on.
VB.NET:
Form1
lblStatus.Text = ""
Sub bMakeChange_Click()
Dim frm2 As New Form2
frm2.OpenDialog()
End Sub
Sub Refresh_lblStatus() 'Option 1 I tried, this is called from
Dim frm2 As New Form2 'bOk_Click() on form 2
lblStatus.Text = frm2.Status.Text
End Sub
-----------------------------------------------
Form2
'stuff here
Sub bOk_Click()
Dim Status
Status.Text = 1
Dim frm1 As New Form1
frm1.Refresh_lblStatus() 'Did not work what am I missing?
frm1.lblStatus.Text = Status.Text 'I also tried this (without) the line above,
Me.Close() 'but form1 has to refresh to have
End Sub 'changes applied correct?
Thanks,
Michael
I have searched on this but one article I went to wouldn't refresh the new labels on form 1 and form 1 is the main form so if it closes the whole program closes... that's why I have it initially open visible=false and load up a frmlogin.showdialog()
Last edited: