Я хотел бы расширить FolderBrowserDialog, чтобы иметь возможность включать подпапки для выбранной папки (добавьте флажок, чтобы включить или отключить). Я узнал, что я не могу расширить основной FolderBrowserDialog, поскольку он является закрытым классом.Как создать пользовательский элемент управления, полученный из класса CommonDialog
Поэтому я считаю, что самым простым решением было бы создать пользовательский элемент управления, который является производным от CommonDialog (тот же класс, что и FolderBrowserDialog), скопируйте код из стандартного FolderBrowserDialog и немного измените его, чтобы он также имел флажок «Включить подпапки».
Но когда я скопировал код из умолчанию FolderBrowserDialog он дает мне ошибку:
missing partial modifier on declaration of type [my_class_name] another partial declaration of this type exists c#
И это указывает на файл «[my_class_name] .Designer.cs».
namespace my_custom_folder_open
{
// Summary:
// Prompts the user to select a folder. This class cannot be inherited.
[DefaultEvent("HelpRequest")]
[DefaultProperty("SelectedPath")]
[Designer("System.Windows.Forms.Design.FolderBrowserDialogDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public sealed class UserControl2 : CommonDialog
{
// Summary:
// Initializes a new instance of the System.Windows.Forms.FolderBrowserDialog
// class.
public UserControl2();
// Summary:
// Gets or sets the descriptive text displayed above the tree view control in
// the dialog box.
//
// Returns:
// The description to display. The default is an empty string ("").
[Browsable(true)]
[DefaultValue("")]
[Localizable(true)]
public string Description { get; set; }
//
// Summary:
// Gets or sets the root folder where the browsing starts from.
//
// Returns:
// One of the System.Environment.SpecialFolder values. The default is Desktop.
//
// Exceptions:
// System.ComponentModel.InvalidEnumArgumentException:
// The value assigned is not one of the System.Environment.SpecialFolder values.
[Browsable(true)]
[Localizable(false)]
public Environment.SpecialFolder RootFolder { get; set; }
//
// Summary:
// Gets or sets the path selected by the user.
//
// Returns:
// The path of the folder first selected in the dialog box or the last folder
// selected by the user. The default is an empty string ("").
[Browsable(true)]
[DefaultValue("")]
[Localizable(true)]
public string SelectedPath { get; set; }
//
// Summary:
// Gets or sets a value indicating whether the New Folder button appears in
// the folder browser dialog box.
//
// Returns:
// true if the New Folder button is shown in the dialog box; otherwise, false.
// The default is true.
[Browsable(true)]
[DefaultValue(true)]
[Localizable(false)]
public bool ShowNewFolderButton { get; set; }
// Summary:
// Occurs when the user clicks the Help button on the dialog box.
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public event EventHandler HelpRequest;
// Summary:
// Resets properties to their default values.
public override void Reset();
protected override bool RunDialog(IntPtr hWndOwner);
}
}
Где может быть проблема?
Btw Я создал проект, как Windows Forms Library управления ..
Я отредактировал ваше название. Пожалуйста, смотрите: «Если вопросы включают« теги »в их названиях?] (Http://meta.stackexchange.com/questions/19190/), где консенсус« нет, они не должны ». –