Results 1 to 5 of 5

Thread: [2005] Open File Dialog filter problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    257

    [2005] Open File Dialog filter problem

    I wrote the filter for my openfiledialog object like this:

    ofd.Filter = "Access Database (*.mdb)|"

    and I think that's correct and it does show up as the only option for filetypes when the ofd opens but the files shown in the actual ofd when it comes up are any type. I could choose a jpg instead of I wanted. So the filter isn't really doing anything at all except changing what the filetype dropdown says. How can I get it to actually enforce my filter rules with what files are able to be chosen?
    I tried to end process on Visual Studio 2005
    but PETA stopped me saying it's smart enough
    to be a living creature

  2. #2
    Addicted Member
    Join Date
    May 2006
    Location
    Manchester, England
    Posts
    255

    Re: [2005] Open File Dialog filter problem

    Try:
    Code:
    ofd.Filter = "Access Database (*.mdb)|*.mdb"
    At home - VB.NET 2005/2008 Express, Visual Web Developer 2005 Express
    At work - VS 2008 Standard (VB)
    .NET 2.0/3.5


    Visual Studio Express Learning Centre | How do I videos | MSDN VB Express Forum | MSDN VB Developer Centre

  3. #3
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    UK
    Posts
    489

    Re: [2005] Open File Dialog filter problem

    Quote Originally Posted by penguin5000
    Try:
    Code:
    ofd.Filter = "Access Database (*.mdb)|*.mdb"
    2nd that, thats how I write filters.
    Learning C♯

    Data Binding & Bound Controls - Objects and wizards will never be as intelligent as you, do it yourself! (Unless your Pro)

  4. #4
    Lively Member
    Join Date
    Aug 2007
    Posts
    66

    Re: [2005] Open File Dialog filter problem

    The problem is you have only set the text that shows in the filter drop down box. You haven't set any actual filters. The filters go after the |.
    Code:
    ofd.Filter = "Access Database (*.mdb)|*.mdb"
    You can add more filters by seperating them with simicolons like this.
    Code:
    ofd.Filter = "Access Database (*.mdb)|*.mdb; *.txt"

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    257

    Re: [2005] Open File Dialog filter problem

    I feel dumb now lol. Just think how dumb I'll be after 2 pounds of turkey lol. I better wait until tomorrow to work on it more
    I tried to end process on Visual Studio 2005
    but PETA stopped me saying it's smart enough
    to be a living creature

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