Why FolderBrowserDialog dialog does not scroll to selected folder?

前端 未结 14 1607
失恋的感觉
失恋的感觉 2020-11-30 02:28

As show in this screen shot, the selected folder is not in the view. It needs to be scrolled down to view the selected folder.

14条回答
  •  隐瞒了意图╮
    2020-11-30 02:34

    I have used a workaround from https://www.daniweb.com/software-development/csharp/threads/300578/folderbrowserdialog-expanding-the-selected-directory-

    FolderBrowserDialog^ oFBD = gcnew FolderBrowserDialog;
    oFBD->RootFolder = Environment::SpecialFolder::MyComputer;
    oFBD->SelectedPath = i_sPathImport;
    oFBD->ShowNewFolderButton = false;     // use if appropriate in your application
    SendKeys::Send ("{TAB}{TAB}{RIGHT}");  // <<-- Workaround
    ::DialogResult oResult = oFBD->ShowDialog ();
    

    It's not the nicest way, but it works for me.
    Without the RootFolder it does NOT work on the first call, but on the 2nd and following. With it, it works always.

    As others have observed that this failure is dependent on the operating system:
    I am using Win 7 Pro x64 SP1

提交回复
热议问题