Open a custom form on Edit

8 posts, 0 answers
  1. VaL
    VaL avatar
    2 posts
    Member since:
    Oct 2017

    Posted 06 Dec 2017 Link to this post

    Hi all,

    I'm trying to customize an item,but I'm stuck, I hope someone could help...

    What I need is to show inside my PropertyGrid a value (a string) with a button aside (the typical [...] ).

    Clicking the button will open up a custom form, from which a new value can be selected.

    So something like the following code, which I've found in another thread:

    private void RadPropertyGrid1_EditorRequired(object sender, PropertyGridEditorRequiredEventArgs e)
            {
                if (e.Item.Name == "DatoStringa")
                {
                    var editor = new PropertyGridBrowseEditor();
                    var el = editor.EditorElement as RadBrowseEditorElement;
                    el.DialogType = BrowseEditorDialogType.FolderBrowseDialog;
                    e.Editor = editor;
                }
            }

     

    That's fine, but I need a brand new form, not a predefined one.

    Is this possible?

    Thank you!

     

  2. VaL
    VaL avatar
    2 posts
    Member since:
    Oct 2017

    Posted 06 Dec 2017 Link to this post

    To be complete... 

    The value will be inside a combobox. The form will be used only for selecting a value through a refined search.

  3. Dimitar
    Admin
    Dimitar avatar
    2019 posts

    Posted 11 Dec 2017 Link to this post

    Hi Valerio,

    So you want a combo box with an additional button that opens a form. To achieve this you can use PropertyGridDropDownListEditor and add new RadButtonElement to it. Here is an example:
    private void RadPropertyGrid1_EditorRequired(object sender, Telerik.WinControls.UI.PropertyGridEditorRequiredEventArgs e)
    {
        if (e.Item.Name == "Text")
        {
            var editor = new PropertyGridDropDownListEditor();
            var button = new RadButtonElement();
            button.Text = "...";
            button.StretchHorizontally = false;
      
            button.Click += Button_Click;
            var element = editor.EditorElement as BaseDropDownListEditorElement;
            element.Children[2].Children.Add(button);
            e.Editor = editor;
        }
    }
      
    private void Button_Click(object sender, EventArgs e)
    {
        //show your form here
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  4. ROBERTA
    ROBERTA avatar
    4 posts
    Member since:
    Dec 2017

    Posted 14 Dec 2017 in reply to Dimitar Link to this post

    Thank you Dimitar for this code, it's really helpful!

     

  5. ROBERTA
    ROBERTA avatar
    4 posts
    Member since:
    Dec 2017

    Posted 14 Dec 2017 in reply to ROBERTA Link to this post

    Just a question more about this code: 

    which is the best way to fill this combo with a custom set of string?

  6. ROBERTA
    ROBERTA avatar
    4 posts
    Member since:
    Dec 2017

    Posted 14 Dec 2017 in reply to ROBERTA Link to this post

    Just a question more about this code...

    Which is the best way to fill this PropertyGridDropDownListEditor with a set of custom strings (not an enum) ?

    Thanks!

  7. ROBERTA
    ROBERTA avatar
    4 posts
    Member since:
    Dec 2017

    Posted 14 Dec 2017 in reply to ROBERTA Link to this post

    I think I've figured it out...

    element.Items.Add("ART001");
    element.Items.Add("ART002");
    element.Items.Add("ART003");

     

    Simple as that!

  8. Dimitar
    Admin
    Dimitar avatar
    2019 posts

    Posted 18 Dec 2017 Link to this post

    Hello Roberta,

    Indeed this is the way to just add some text items. Another approach would be to bind to a list:
    element.DataSource = new List<string>() { "Item 1", "Item 2", "Item 3" };

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top