Gr33tings krazy k0d3 m0nk3yz!
Today, we will be working with menu stuff again BEFORE you get to work on your projects. So open up that menu project you have stored somewhere in your vast archive of programming fun, and let's get started!
OK, ready? Here's the first you have to do:
A) You already have a thing called a menustrip at the bottom of your form. You are going to drag an "OpenFileDialog" thingamabob next to it. Just scroll down the list of controls at left and you should see it in there somewhere.
B) Now you will have to connect this new control to an item on your menu. There's an "Open" menuitem available so doubleclick on it to get into its code
C) We're going to do this a piece at a time, so let's start with some very simple things. Type in this following code:
'this says where you start
OpenFileDialog1.InitialDirectory = "C:\"
'this just gives a title to the dialog box
OpenFileDialog1.Title = "Open a Text File"
'this says which kind of files to look for
OpenFileDialog1.Filter = "Text Files*.txt"
'this opens a fileDialog, so you can go looking for files
OpenFileDialog1.ShowDialog( )
Basically (hahaha Ryan) this code makes a FileOpen dialog box pop up when you click on the Open menuitem. It will start in the main directory of your hard drive, and it will ONLY look for text files. Plus, it will have a cool title that says its only looking for text files. Try it and see what you get!
Cheers,
Mr. L
Saturday, November 8, 2008
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment