admin管理员组文章数量:1291027
The OpenFileDialog()
has this capability.
I need the same capability in the FolderBrowserDialog()
.
For example, I want the area in the red box to be shown in the FolderBrowserDialog:
This is how I am currently calling it:
/// <summary>
/// Browse and select folder event handler.
/// </summary>
/// <param name="mopParameter">The mopParameter.</param>
/// <param name="rowIndex">The index of the DataGridView row being edited.</param>
private void FolderBrowserDialog_Open(MOPParameter mopParameter, Int32 rowIndex)
{
try
{
var cellValue = this.dataGridView.Rows[rowIndex].Cells[2].Value.ToString();
var folderBrowserDialog = new FolderBrowserDialog
{
SelectedPath = cellValue,
};
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
this.dataGridView.Rows[rowIndex].Cells[2].Value = folderBrowserDialog.SelectedPath;
MOPParameterUtil.MOPParameterSetValue(
this.mopParameters, mopParameter.ParameterName, folderBrowserDialog.SelectedPath);
}
folderBrowserDialog.Dispose();
}
catch (Exception e)
{
MessageBox.Show(
this,
@"Error selecting folder." + Environment.NewLine + e.Message,
@"Configure MOP Options",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
The OpenFileDialog()
has this capability.
I need the same capability in the FolderBrowserDialog()
.
For example, I want the area in the red box to be shown in the FolderBrowserDialog:
This is how I am currently calling it:
/// <summary>
/// Browse and select folder event handler.
/// </summary>
/// <param name="mopParameter">The mopParameter.</param>
/// <param name="rowIndex">The index of the DataGridView row being edited.</param>
private void FolderBrowserDialog_Open(MOPParameter mopParameter, Int32 rowIndex)
{
try
{
var cellValue = this.dataGridView.Rows[rowIndex].Cells[2].Value.ToString();
var folderBrowserDialog = new FolderBrowserDialog
{
SelectedPath = cellValue,
};
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
this.dataGridView.Rows[rowIndex].Cells[2].Value = folderBrowserDialog.SelectedPath;
MOPParameterUtil.MOPParameterSetValue(
this.mopParameters, mopParameter.ParameterName, folderBrowserDialog.SelectedPath);
}
folderBrowserDialog.Dispose();
}
catch (Exception e)
{
MessageBox.Show(
this,
@"Error selecting folder." + Environment.NewLine + e.Message,
@"Configure MOP Options",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
Share
Improve this question
edited Feb 20 at 16:09
Bruce B Wilson
asked Feb 13 at 16:10
Bruce B WilsonBruce B Wilson
417 bronze badges
1 Answer
Reset to default 1You can use the System.Home
CLSID: 679f85cb-0220-4080-b29b-5540cc05aab6
(you can find it in the Registry) to instruct the FolderBrowserDialog to set the InitialDirectory
to the Quick Access path, adding the shell:::
prefix.
Simple example:
using var fbDialog = new FolderBrowserDialog() {
InitialDirectory = "shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}"
};
fbDialog.ShowDialog();
The same CLSID is used in both Windows 10 and Windows 11, but I've tested this in Windows 10 only
The dotted CLSID form, .{Some Special Folder CLSID}
does not work here.
This of course (given the Property used), refers to .NET's FolderBrowserDialog, not the class exposed by .NET Framework
版权声明:本文标题:winforms - How can I include the "Quick Access" pane in the FolderBrowserDialog() in c# - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741518384a2383033.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论