Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Filter not working correctly in OpenFileDialog

Filter not working correctly in OpenFileDialog

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestion
3 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ricecake
    wrote on last edited by
    #1

    Hello, I am experiencing some weirdness with my OpenFileDialog filter. When I first open the dialog, the filter works and shows me the files with the filename scheme that I specify. However, if I select a different filter, then all the files disappear from the list. In addition, if I manually type the filter into the filename field and press Enter, then the files show up again. Here is a snippet where I create the dialog:

    System::Void button_xmtr_Click(System::Object *  sender, System::EventArgs *  e)
    {
    	OpenFileDialog* dlg = new OpenFileDialog();
    	dlg->Title = S"Choose Transmitter file";
    	dlg->InitialDirectory = S"input";
    	dlg->Filter = S"Transmitter files (xmtr*.dat)|xmtr*.dat|DAT files (*.dat)|*.dat|All files (*.*)|*.*";
    	if (dlg->ShowDialog() == DialogResult::OK) {
    		textbox_xmtr->Text = dlg->FileName;
    	}
    }
    

    Has anybody else run into this problem? Does anybody know of a workaround? Thanks. -- Marcus Kwok

    R 2 Replies Last reply
    0
    • R ricecake

      Hello, I am experiencing some weirdness with my OpenFileDialog filter. When I first open the dialog, the filter works and shows me the files with the filename scheme that I specify. However, if I select a different filter, then all the files disappear from the list. In addition, if I manually type the filter into the filename field and press Enter, then the files show up again. Here is a snippet where I create the dialog:

      System::Void button_xmtr_Click(System::Object *  sender, System::EventArgs *  e)
      {
      	OpenFileDialog* dlg = new OpenFileDialog();
      	dlg->Title = S"Choose Transmitter file";
      	dlg->InitialDirectory = S"input";
      	dlg->Filter = S"Transmitter files (xmtr*.dat)|xmtr*.dat|DAT files (*.dat)|*.dat|All files (*.*)|*.*";
      	if (dlg->ShowDialog() == DialogResult::OK) {
      		textbox_xmtr->Text = dlg->FileName;
      	}
      }
      

      Has anybody else run into this problem? Does anybody know of a workaround? Thanks. -- Marcus Kwok

      R Offline
      R Offline
      ricecake
      wrote on last edited by
      #2

      OK, now I'm really confused. I used this exact same code in a test app and it works perfectly there! It still does not work right in my main app though :confused: -- Marcus Kwok

      1 Reply Last reply
      0
      • R ricecake

        Hello, I am experiencing some weirdness with my OpenFileDialog filter. When I first open the dialog, the filter works and shows me the files with the filename scheme that I specify. However, if I select a different filter, then all the files disappear from the list. In addition, if I manually type the filter into the filename field and press Enter, then the files show up again. Here is a snippet where I create the dialog:

        System::Void button_xmtr_Click(System::Object *  sender, System::EventArgs *  e)
        {
        	OpenFileDialog* dlg = new OpenFileDialog();
        	dlg->Title = S"Choose Transmitter file";
        	dlg->InitialDirectory = S"input";
        	dlg->Filter = S"Transmitter files (xmtr*.dat)|xmtr*.dat|DAT files (*.dat)|*.dat|All files (*.*)|*.*";
        	if (dlg->ShowDialog() == DialogResult::OK) {
        		textbox_xmtr->Text = dlg->FileName;
        	}
        }
        

        Has anybody else run into this problem? Does anybody know of a workaround? Thanks. -- Marcus Kwok

        R Offline
        R Offline
        ricecake
        wrote on last edited by
        #3

        Solution here: http://www.codeproject.com/script/comments/forums.asp?msg=1611776&forumid=3785#xx1611776xx[^]

        -- Marcus Kwok

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups