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

Assing Field Editor In Code

1 Answer 116 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 30 Mar 2021, 03:46 PM
How to assign the editor control type of a dynamically added property in code. I do not want to set the EditorTemplate nor do I want to use EditorAttributes...

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 01 Apr 2021, 08:08 AM

Hi Alexander,

Using EditorTemplate or EditorAttributes is the way to change the default editor for a property. I am afraid that I am out of options here. Still, you can reconsider using the EditorTemplate property. You can set it in code. For example, you can subscribe to the AutoGeneratingPropertyDefinition event of the control. In the event handler, you can get the current generated property definition and set its EditorTemplate.

private void radPropertyGrid_AutoGeneratingPropertyDefinition(object sender, AutoGeneratingPropertyDefinitionEventArgs e)
{
    e.PropertyDefinition.EditorTemplate = this.Resources["MyEditorTemplate"] as DataTemplate;
}

Regards,
Dinko
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
PropertyGrid
Asked by
Alexander
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or