|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem Communicating Between FormsI have a main form which has a list of items from a table on my
database. If I click one of these items it brings up a second form which lets you edit the details for that item. If I change an item's details and then close the edit form I want the main form to update its datagrid by calling the sub I wrote which refreshes the dataset. What is the best method of doing this; I know I can call commands after a showdialog form but I really don't want to use showdialog instead of show. Any help would be greatly appreciated. Please try and be specific as I'm still quite new to the Dot Net way of doing things. Jasper,
> Why because if you use another from than you will have to do a lot with all > What is the best method of doing this; I know I can call commands after > a showdialog form but I really don't want to use showdialog instead of > show. > those extra forms that a user is opening meanwhile on the first form. You have to prevent that your first form can be accessed. Showdialog does this direct for you. Cor Simple Solution:
Have the first form subscribe to the second form's Closing event... like this: Dim frm as New Form2 AddHandler(frm.Closing, AddressOf MyForm2ClosingProc) frm.Show You can also create a new custom event in the second form that could communicate additional info to the first form. Better Solution Create a global Notifier class that forms can subscribe to and "hear" chatter from other forms. When the second form is closing it can do something like: GlobalNotifier.SendNotification(Me,"Hey I'm Closing AND I updated some data") This is soooo simple to do. 'declare this in a global module Public GlobalNotifier As New Notifier 'notifier class Public Class Notifier Public Event Notify(sender As Object, e As NotifyEventArgs) Public Sub SendNotifications(sender As Object, message as String) RaiseEvent Notify(sender, New NotifyEventArgs(message)) End Sub End Class '... I think you can figure out the rest. Show quoteHide quote "Jasper Jones" <jasper***@gmail.com> wrote in message news:1139097125.941950.249540@f14g2000cwb.googlegroups.com... >I have a main form which has a list of items from a table on my > database. If I click one of these items it brings up a second form > which lets you edit the details for that item. If I change an item's > details and then close the edit form I want the main form to update its > datagrid by calling the sub I wrote which refreshes the dataset. > > What is the best method of doing this; I know I can call commands after > a showdialog form but I really don't want to use showdialog instead of > show. > > Any help would be greatly appreciated. Please try and be specific as > I'm still quite new to the Dot Net way of doing things. >
Newbie Question 2, Reference To Controls On A Form
Problem to write a good serie of bytes in a file. Additional information: Cast from string "" to type 'Double' is not valid. error Visual Basic 2005 Report writers for VB.NET current working directory problem Newbie Question Saving Projects late bound form reference taskbar icon Making Bitmaps and Graphics objects - two ways |
|||||||||||||||||||||||