Results 1 to 5 of 5

Thread: How to fire the Save/Open and Cancel button of a Open/SaveFileDialog? [Resolved]

  1. #1

    Thread Starter
    Registered User
    Join Date
    Apr 2003
    Location
    Klang, Selangor, Malaysia
    Posts
    163

    Question How to fire the Save/Open and Cancel button of a Open/SaveFileDialog? [Resolved]

    How to fire the Save/Open and Cancel button of a Open/SaveFileDialog?
    Last edited by albertlse; Aug 21st, 2003 at 08:26 PM.

  2. #2
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    Palermo, Italy
    Posts
    325
    Click on it . No no, firing events is a thing I'm looking for... In VB6 we could do this by SendMessage Windows API, but now??
    Learn, this is the Keyword...

  3. #3
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    I am not at my machine now, but I am sure you can easily RaiseEvent in VB.NET and also you can easily send message. Will post the code soon.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  4. #4
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    Please skip if this is too remedial but I don't know what you know...
    As far as I have been taught you don't fire the events of common dialogs, you run them and examine what they return like so:

    VB Code:
    1. Dim myStream As Stream
    2.     Dim openFileDialog1 As New OpenFileDialog()
    3.        
    4.     openFileDialog1.InitialDirectory = "c:\"
    5.     openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
    6.     openFileDialog1.FilterIndex = 2
    7.     openFileDialog1.RestoreDirectory = True
    8.  
    9.     [b]If openFileDialog1.ShowDialog() = DialogResult.OK Then[/b]
    10.         myStream = openFileDialog1.OpenFile()
    11.         If Not (myStream Is Nothing) Then
    12.             ' Insert code to read the stream here.
    13.             myStream.Close()
    14.         End If
    15.     End If

    What the above code does is first set up the objects used (particularly the OpenFileDialog) and then, where the bold is, it shows the OpenFileDialog and examines the return from it, which is expected to be a member of the DialogResult enumeration, one of which is OK (others are Cancel, Yes, No, etc). Note that the code that actually reads the file is absolutely nothing to do with the OpenFileDialog itself.

  5. #5

    Thread Starter
    Registered User
    Join Date
    Apr 2003
    Location
    Klang, Selangor, Malaysia
    Posts
    163
    it's working fine now! thank you.

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