FolderBrowserDialog in PropertyGrid

3 posts, 1 answers
  1. Artem
    Artem avatar
    16 posts
    Member since:
    May 2013

    Posted 09 Dec 2012 Link to this post

    In my application I use RadPropertyGrid and I create set of properties for it in my code using RadPropertyStore.

    Before I started to use RadPropertyGrid all properties were displayed in group-boxes with different controls like text-box, drop-down and button. It was a mess.
    One of the properties should contain path to some local directory. And in old implementation it was displayed by text box and browse button that was opening FolderBrowserDialog 
    As you might already imagine, my question is how can I insert FolderBrowserDialog to RadPropertyGrid?
    What I have managed to do is below:
        public partial class SettingsManager : UserControl
            public SettingsManager()
                _propertyStore = CreateProperties();
                radPropertyGrid1.SelectedObject = _propertyStore;
                radPropertyGrid1.PropertySort = PropertySort.CategorizedAlphabetical;
            private RadPropertyStore _propertyStore;
            private PropertyStoreItem _defaultSaveDirectory;
            private RadPropertyStore CreateProperties()
                var result = new RadPropertyStore();
                _defaultSaveDirectory = new PropertyStoreItem(typeof(string),
                                                            "Default directory for saving snapshot and configuration files.",
                                                            "Save Snapshot/Configuration",
                _defaultSaveDirectory.PropertyChanged += OnDefaultSaveDirectoryChanged;
                return result;
            void OnDefaultSaveDirectoryChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
                var folderDialog = new FolderBrowserDialog {
                                                               Description = Resources.DefaultLocationDialogHelp,
                                                               ShowNewFolderButton = true
                if (DialogResult.OK == folderDialog.ShowDialog())
                    _defaultSaveDirectory.PropertyChanged -= OnDefaultSaveDirectoryChanged;
                    _defaultSaveDirectory.Value = folderDialog.SelectedPath;
                    _defaultSaveDirectory.PropertyChanged += OnDefaultSaveDirectoryChanged;
                    Properties.Settings.Default.DefaultSaveFolderPath = folderDialog.SelectedPath;

    But I have two problems with this implementation:
    1) FolderBrowserDialog opens on initialization
    2) There is no such a thing like Click event for PropertyStoreItem, so user have to really change the property value in order to FolderBrowserDialog to appear

  2. Artem
    Artem avatar
    16 posts
    Member since:
    May 2013

    Posted 12 Dec 2012 Link to this post

    Sorry, guys :)
    I have found the solution in this thread:
    Property editor displays a dialog

    It describes how to add button to text editor of string property. I just modified the click event handler to open FolderBrowserDialog and that is it :)
    Thanks for great control (RadPropertyGrid)
  3. DevCraft R3 2016 release webinar banner
  4. Answer
    Ivan Petrov
    Ivan Petrov avatar
    701 posts

    Posted 12 Dec 2012 Link to this post

    Hello Artem,

    Thank you for writing.

    The approach you have found is one way to go. The other is to use the already available in RadPropertyGrid PropertyGridBrowseEditor. All you have to do is subscribe to the EditorRequired event and change the editor. Here is a code snippet:
    private void radPropertyGrid1_EditorRequired(object sender, PropertyGridEditorRequiredEventArgs e)
      PropertyGridBrowseEditor editor = new PropertyGridBrowseEditor();
      RadBrowseEditorElement element = editor.EditorElement as RadBrowseEditorElement;
      element.DialogType = BrowseEditorDialogType.FolderBrowseDialog;
      e.Editor = editor;

    I hope this will help. Feel free to write back with any further questions.
    All the best,
    Ivan Petrov
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top