Results 1 to 6 of 6

Thread: Browse button!!!!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    142

    Question Browse button!!!!

    hi guys,
    i need to make a browse button which when clicked should open a window where i can search the file that i need to open. it is the same function that we normally see in MS word or other tools.
    thanks.

  2. #2
    Addicted Member
    Join Date
    Feb 2006
    Location
    Maryland
    Posts
    182

    Re: Browse button!!!!

    a file dialog screen?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    142

    Re: Browse button!!!!

    i dont know what is that. actually i need to make a menubar. in vb.net its menustrip. i need to make a similar menubar as of MS word.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,274

    Re: Browse button!!!!

    Just add a Button control to your form, double-click it to create a Click event handler and then display an OpenFileDialog. You can add the OpenFileDialog to the form in the designer or you can create one in code on demand. I'd be inclined to use the designer as setting the properties is easier but if you want to do it in code it would look something like this:
    VB Code:
    1. Private Sub browseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles browseButton.Click
    2.     Using ofd As New OpenFileDialog
    3.         ofd.Filter = "All files (*.*)|*.*"
    4.         ofd.Title = "Select File"
    5.  
    6.         If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
    7.             MessageBox.Show("You selected " & ofd.FileName)
    8.         End If
    9.     End Using
    10. End Sub
    Note that this is VB 2005 and will not work as is in previous versions. Please specify your version in future.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,274

    Re: Browse button!!!!

    OK, MenuStrip means you're using VB 2005. So, do you want a button or a menu? Either way you can still handle the Click event of a ToolStripMenuItem (menu) or a ToolStripButton (tool bar) so it's the same thing.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    142

    Re: Browse button!!!!

    thnx buddy. thnx a lot.

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