Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Dialog Box (.Net 2003)

    If a main form calls a dialog box,
    1) what is the best way to start the dialog form?
    2) what is the best way for the information entered on the form to be passed back to the main form?
    3) how does the main form know that the dialog has exited?

    TIA --Sam, still <img src=/S/confused.gif border=0 alt=confused width=15 height=20> with multiple forms
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dialog Box (.Net 2003)

    Well, I think that I can answer those questions, but if someone will tell me I'm correct, I'd appreciate it.
    > 1) what is the best way to start the dialog form?
    ShowDialog
    > 2) what is the best way for the information entered on the form to be passed back to the main form?
    set the Modifiers property to public so you can reference it from the main after ShowDialog returns
    > 3) how does the main form know that the dialog has exited?
    control does not return to the main until the dialog has closed
    In addition, ShowDialog returns a DialogResult identifier

    Another (related) question: supposed I wanted the form to be a tool window with just a sigle TrackBar control on it (no button). I would like for both the tool and the parent window to have an event when the TrackBar changes. Plus, I would like for the tool window to disappear when the mouse is clicked on the parent.
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dialog Box (.Net 2003)

    Sam, you already answered your other questions, so should we wait for you to answer this one? <img src=/S/innocent.gif border=0 alt=innocent width=20 height=20>

    Both parent and child forms can raise custom events using RaiseEvent and passing a sender object and an EventArgs object. The other form can sink the event by having a handler that handles the custom event of the other form. The popup form can raise a TrackBarChange event and the parent form can raise a MouseClick event.

    The popup would declare an event like this and use RaiseEvent to call it

    <code>Public Event TrackBarChange(ByVal sender As Object, ByVal e As System.EventArgs)</code>

    The parent form would sink the event by declaring a module level variable for the form and having a handler for its event.

    <code>WithEvents frm as New frmTrackBar

    Private Sub HandleTrackBarChange(byval sender as Object, byval e as System.EventArgs) Handles frmTrackBar.TrackBarChange
    ...
    End Sub</code>

    You would, of course call the popup using <code>frmTrackBar.ShowDialog()</code>

    Does that help?
    Charlotte

Posting Permissions

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