|
-
Jun 25th, 2003, 08:52 PM
#1
Thread Starter
Addicted Member
Form gotfocus trigger?
Hey everybody...just started porting all our programs to VB.NET and love the language but miss some of the straightforward ways of doing things in good old VB6.
Here is the situation (oversimplified but you get my point).
I have one main form with a command button
Clicking the command button fires the code to bring up a clients purchase order.
VB Code:
Dim frm As New frmShowPurchaseOrder()
frm.WindowState = FormWindowState.Normal
frm.Show()
This form has a button that, when clicked, fires the code to bring up a listing of products.
VB Code:
Dim frm As New frmShowProducts()
frm.WindowState = FormWindowState.Normal
frm.Show()
The user then selects a product and hits submit. The product is added to the purchase order (through sql server SP's), and the form is closed.
The problem lies in that i don't know how to set focus back to the PurchaseOrder form in order to tell itto refresh the datagrid that holds all products.
At this point i am using
VB Code:
Private Sub frmShowPurchaseOrder_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
If g_intFormMaterialActivate >= 1 Then
Else
MsgBox("I am activated")
UpdateMaterialDataGrid()
'so they only fire it once
g_intFormMaterialActivate += 1
End If
End Sub
To fire the UpdateProductDataGrid() function call but it means that the user has to move the mouse and i want it to happen automatically.
How can i do this once the form has focus?
Sorry this has been so longwinded but i hate questions that are asked with too little detail.
(although this may stretch the bounds ).
Thanks in advance!!
Soylent Green tastes like chicken
-
Jun 26th, 2003, 03:19 PM
#2
Sleep mode
I dunno if this would help you but you can try giving the form focus when after closing the previous form like this :
In the closing event :
VB Code:
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Form1.Focus()
End Sub
-
Jun 26th, 2003, 03:31 PM
#3
PowerPoster
Instead of using the Show() method, use the ShowDialog(me) method.
This will make the code stop executing at the ShowDialog call on the first form, and when that form is closed, you can then do what you need.
Example.
Dim frm As New frmShowPurchaseOrder()
frm.WindowState = FormWindowState.Normal
frm.ShowDialog(Me)
'Execution stops until frm is closed.
'Do processing here when frm is closed.
Dim frm As New frmShowProducts()
frm.WindowState = FormWindowState.Normal
frm.ShowDialog(Me)
'Execution stops until frm is closed.
'Do processing here that has to be done when that form is closed.
-
Jun 26th, 2003, 03:42 PM
#4
Thread Starter
Addicted Member
NICE!!
Hellswraith, if i am ever coming down to Utah I owe you a couple of beers! Been trying to figure out how to do this for a week now.
Figured there had to be a way to do it.
You chopped about 250 lines of code out of my program.
Thanks again
Soylent Green tastes like chicken
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|