How do you make an open file dialog?
- plushiefire
- Posts: 618
- Joined: Thu Nov 23, 2006 12:10 pm
- Location: Canada
How do you make an open file dialog?
Sorry but i really need to know. Im trying to make a resigner.
Come check out Team 3volved.
- jebmodillion
- Readers Club
- Posts: 41
- Joined: Sun Apr 08, 2007 9:43 pm
Ok well if you are looking to make your own resigner the go to the following link:
http://forums.halomods.com/viewtopic.php?t=60019
About the open file dialog:
I am assuming you are using visual basic
so do this
Go to the tool box in Visual baisc (with project open) then go to dialogs catagory in the tool box after that drag and drop it on the design form of your resigner. It wont appear on your resigner disign it will be located right below it you will see OpenFileDialog1 click it once then go to the propertys window(usualy located to the lower right) and find the tag named(name) then change it to ofd.
If you need further help PM me and I will teach you to the best of my knowledge.
http://forums.halomods.com/viewtopic.php?t=60019
About the open file dialog:
I am assuming you are using visual basic
so do this
Go to the tool box in Visual baisc (with project open) then go to dialogs catagory in the tool box after that drag and drop it on the design form of your resigner. It wont appear on your resigner disign it will be located right below it you will see OpenFileDialog1 click it once then go to the propertys window(usualy located to the lower right) and find the tag named(name) then change it to ofd.
If you need further help PM me and I will teach you to the best of my knowledge.
assuming you know C#
1.) Drag over an open file dialog from containers and menus in the toolbatr in C#.
2.) Double click your open event and copy n paste this code to open a .map file.
1.) Drag over an open file dialog from containers and menus in the toolbatr in C#.
2.) Double click your open event and copy n paste this code to open a .map file.
Code: Select all
OpenFileDialog OFD = new OpenFileDialog();
OFD.Filter = "Map(*.map)|*.map";
OFD.FilterIndex = 1;
if (OFD.ShowDialog() == DialogResult.OK)
{
// Load the contents of the .map file here.
}
VB: It opens an image (you can change it to something else) and when you open it it shows it's location in a textbox.
Short answer:
ofdSelectPicture is the name of your ofd.
Code: Select all
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
' Show the open file dialogue box.
If ofdSelectPicture.ShowDialog = Windows.Forms.DialogResult.OK Then
' Load the picture in the picture box.
picShowPicture.Image = Image.FromFile(ofdSelectPicture.FileName)
' show the name of the file's location in a text box
txtDestination.Text = "" & ofdSelectPicture.FileName
End If
End Sub
Short answer:
Code: Select all
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
' Show the open file dialogue box.
If ofdSelectPicture.ShowDialog = Windows.Forms.DialogResult.OK
End Sub
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
- LuxuriousMeat
- Posts: 824
- Joined: Thu Nov 03, 2005 6:43 pm
- Location: zzzzzzzzzzzzzzzz
- Contact:
Why are giving him unfinished code?
To make it easy just use this:
To make it easy just use this:
Code: Select all
Dim ofd As New OpenFileDialog
ofd.Filter = "Halo 2 Maps|*.map"
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
'code for pressing ok here
End If
sorry if it was unfinished, but I copied that from my app where it worked fineLuxuriousMeat wrote:Why are giving him unfinished code?
To make it easy just use this:Code: Select all
Dim ofd As New OpenFileDialog ofd.Filter = "Halo 2 Maps|*.map" If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then 'code for pressing ok here End If
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
that is finished...Patrickh wrote:sorry if it was unfinished, but I copied that from my app where it worked fineLuxuriousMeat wrote:Why are giving him unfinished code?
To make it easy just use this:Code: Select all
Dim ofd As New OpenFileDialog ofd.Filter = "Halo 2 Maps|*.map" If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then 'code for pressing ok here End If
- LuxuriousMeat
- Posts: 824
- Joined: Thu Nov 03, 2005 6:43 pm
- Location: zzzzzzzzzzzzzzzz
- Contact:
Thats the code I posted, he had no End If.halo0001 wrote:that is finished...Patrickh wrote:sorry if it was unfinished, but I copied that from my app where it worked fineLuxuriousMeat wrote:Why are giving him unfinished code?
To make it easy just use this:Code: Select all
Dim ofd As New OpenFileDialog ofd.Filter = "Halo 2 Maps|*.map" If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then 'code for pressing ok here End If
If your going to create an openfiledialog on the fly, you might as well in-close it in a using statement.
Code: Select all
/* Once the using statement has finished, the garbage
* collector knows to dispose of the ofd straight away */
using (OpenFileDialog o = new OpenFileDialog())
{
//Set some properties
o.Title = "Open File Dialog";
o.Filter = "All Files (*.*)|*.*";
if (o.ShowDialog() != DialogResult.Cancel)
{
// The user has selected a file
}
else
{
// Cancel was pressed
}
}
Halo 2 Prophet - Skin with ease with the simple 3D point and click interface.
Halo 3 Research Thread - Contribute to the research into Halo 3.
Halo 3 Research Thread - Contribute to the research into Halo 3.
I understand that all, but what does that do, just dispose it when you're finished or what? I used to use it when I used vb.net, but stopped.Prey wrote:If your going to create an openfiledialog on the fly, you might as well in-close it in a using statement.
Code: Select all
/* Once the using statement has finished, the garbage * collector knows to dispose of the ofd straight away */ using (OpenFileDialog o = new OpenFileDialog()) { //Set some properties o.Title = "Open File Dialog"; o.Filter = "All Files (*.*)|*.*"; if (o.ShowDialog() != DialogResult.Cancel) { // The user has selected a file } else { // Cancel was pressed } }
The using statement makes sure the object is disposed of as soon as the statement is over, otherwise the object will just be floating around in mem. until the GC realizes it's no longer needed. (true that'll probably be as soon as the method ends, but it's still good practice - also you can be sure it'll be disposed of asap)
Halo 2 Prophet - Skin with ease with the simple 3D point and click interface.
Halo 3 Research Thread - Contribute to the research into Halo 3.
Halo 3 Research Thread - Contribute to the research into Halo 3.