|
-
May 25th, 2003, 10:10 PM
#1
Thread Starter
Registered User
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.
-
May 26th, 2003, 02:54 AM
#2
Hyperactive Member
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...
-
May 26th, 2003, 04:30 AM
#3
Frenzied Member
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
-
May 26th, 2003, 02:28 PM
#4
Fanatic Member
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:
Dim myStream As Stream
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True
[b]If openFileDialog1.ShowDialog() = DialogResult.OK Then[/b]
myStream = openFileDialog1.OpenFile()
If Not (myStream Is Nothing) Then
' Insert code to read the stream here.
myStream.Close()
End If
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.
-
May 26th, 2003, 08:44 PM
#5
Thread Starter
Registered User
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|