This is a migrated thread and some comments may be shown as answers.

Open a custom form on Edit

9 Answers 164 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Andrea
Top achievements
Rank 1
Andrea asked on 06 Dec 2017, 03:41 PM

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!

 

9 Answers, 1 is accepted

Sort by
0
Andrea
Top achievements
Rank 1
answered on 06 Dec 2017, 04:45 PM

To be complete... 

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

0
Dimitar
Telerik team
answered on 11 Dec 2017, 07:41 AM
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.
0
Roberta
Top achievements
Rank 1
answered on 14 Dec 2017, 11:13 AM

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

 

0
Roberta
Top achievements
Rank 1
answered on 14 Dec 2017, 11:21 AM

Just a question more about this code: 

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

0
Roberta
Top achievements
Rank 1
answered on 14 Dec 2017, 11:22 AM

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!

0
Roberta
Top achievements
Rank 1
answered on 14 Dec 2017, 03:31 PM

I think I've figured it out...

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

 

Simple as that!

0
Dimitar
Telerik team
answered on 18 Dec 2017, 07:32 AM
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.
0
Eusebio
Top achievements
Rank 1
Veteran
answered on 06 Oct 2020, 12:33 PM
Hello Dimitar,

I am doing it as you indicate, but it does not allow me to edit the text.

I have tried with:
element.DropDownStyle = RadDropDownStyle.DropDown;

but it does not work.
0
Nadya | Tech Support Engineer
Telerik team
answered on 07 Oct 2020, 01:47 PM

Hello, Eusebio,

If I understand your requirement correctly, you need to allow editing the text in the PropertyGridDropDownListEditor. Setting the DropDownStyle property to DropDown is the right way to make the text box editable. Note that the PropertyGridDropDownListEditor accepts only valid values considering the items available in the applied DataSource to the editor. 

However, if your requirement is to allow the end-users to enter free input, it has to be added to the DataSource as a valid item. The following help article demonstrates a sample approach for the drop-down editor in RadGridView. In a similar way, this custom behavior can be achieved for RadPropertyGrid as well: https://docs.telerik.com/devtools/winforms/controls/gridview/editors/how-to/allow-end-users-to-add-items-to-dropdownlisteditor

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Nadya
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
PropertyGrid
Asked by
Andrea
Top achievements
Rank 1
Answers by
Andrea
Top achievements
Rank 1
Dimitar
Telerik team
Roberta
Top achievements
Rank 1
Eusebio
Top achievements
Rank 1
Veteran
Nadya | Tech Support Engineer
Telerik team
Share this question
or