我知道如果我SelectedPath在显示对话框之前设置,我可以在对话框打开时默认打开文件夹.但是,我想要使用的文件夹按字母顺序排在列表的下方.我有一个与Windows中的一个库相同的文件夹,它显示在列表中,是否有任何方法可以将其默认为文件夹的库版本而不是文件夹的硬盘版本?
另一个可能的解决方案是,如果它仍然使用驱动器版本,但它会自动将窗口向下滚动到选定的位置.有没有办法做这些解决方案?
目前如何显示

我多么希望它出现

Kre*_*epN 17
设置您的根文件夹和选定的路径,它将在对话框打开时自动滚动到那里:
FolderBrowserDialog dlg = new FolderBrowserDialog();
dlg.RootFolder = Environment.SpecialFolder.MyComputer;
dlg.SelectedPath = @"E:\Vetcentric";
dlg.ShowDialog();
Run Code Online (Sandbox Code Playgroud)

您遇到的问题是,如果您在选择位于库层次结构中的文件夹后查看属性分配,它仍会将其分配给您通过我的计算机获得的基因路径.
小智 6
使用Reset()调用.这将使其自动滚动.
string prevpath = folderBrowserDialog1.SelectedPath;
folderBrowserDialog1.Reset();
folderBrowserDialog1.SelectedPath = bc.myWorkingDir;
folderBrowserDialog1.ShowNewFolderButton = true;
DialogResult dr = folderBrowserDialog1.ShowDialog();
if (dr == DialogResult.OK || dr == DialogResult.Yes)
{
bc.myWorkingDir = folderBrowserDialog1.SelectedPath;
}
folderBrowserDialog1.SelectedPath = prevpath;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19437 次 |
| 最近记录: |