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

Is it possible to modify the property description at runtime?

1 Answer 73 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Veteran
Steve asked on 27 May 2020, 06:24 AM
There are times when I want certain property descriptions to change as other properties change. How to modify the value of an property description at runtime. Is this feasible? How is this achieved? Thank you!

1 Answer, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 29 May 2020, 01:11 PM

Hello Steve,

Note that the meta data stored in each RadPropertyStore is retrieved when it is first requested and it is cached for subsequent retrieval. If you change the description attribute at run time, the cached data will remain unchanged and the cached one will be returned. Indeed, the internal mechanism of RadPropertyGrid relies on the metadata and the attributes that are assigned to the properties when the RadPropertyStore is initially assigned. This is why if you try to set the PropertyStoreItem.Description property at run time, you shouldn't see the new description.

However, if you want to change the description attribute at run time, the possible solution that I can suggest is to rebind the RadPropertyGrid. An example is demonstrated below:

 public partial class RadForm1 : Telerik.WinControls.UI.RadForm
 {
     PropertyStoreItem floatItem;
     RadPropertyStore store = new RadPropertyStore();
     public RadForm1()
     {
         InitializeComponent();
         floatItem = new PropertyStoreItem(typeof(float),
         "Float", 1f, "Property storing a floating point value.");

         store.Add(floatItem);
         this.radPropertyGrid1.SelectedObject = store;
     }

     private void radButton1_Click(object sender, EventArgs e)
     {
         store = new RadPropertyStore();
         floatItem.Description = "New description";
         store.Add(floatItem);
         this.radPropertyGrid1.SelectedObject = null;
         this.radPropertyGrid1.SelectedObject = store;
     }
 }

I hope this information helps. If you have other questions I will be glad to help.

Regards,
Nadya
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
PropertyGrid
Asked by
Steve
Top achievements
Rank 1
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or