Results 1 to 5 of 5

Thread: VB2005 The right event

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    VB2005 The right event

    Hello,

    I Have a form. (frmForm1)
    On that form is a link to another (frmForm2) form that opens as a dialog.
    When form2 closes I want to perfom an action on form1.
    I tried the Activated event but that is called more often then when I close frmform2.

    The action is only to be performed when form2 closes.

    Does anybody have a suggestion to wich event to use???

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB2005 The right event

    You don't need an event. You display the dialogue by calling ShowDialog and it doesn't return until the form is closed. That means you just perform your action immediately after ShowDialog.

    That's assuming that you want a modal dialogue. If not then you would handle the Closed event of the second form, not an event of the first.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Hyperactive Member
    Join Date
    Apr 2005
    Location
    Indiana
    Posts
    451

    Re: VB2005 The right event

    VisibleChanged should work, else you could include the things you want to do following the code that hides your form.

    Hope that helps.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    Re: VB2005 The right event

    Thank you.

    Once again you guys helped me very very much.

    I did the following:

    VB Code:
    1. Private Sub lblLand_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lblLand.LinkClicked
    2. frmLanden.ShowDialog()
    3. Call FillDataset()
    4. End Sub

    And it works perfectly

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB2005 The right event

    Not that it will do any harm but note that the 'Call' keyword doesn't really serve a purpose in VB.NET. I have heard it said that it improves the readability of code but I can't say that I see that myself.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width