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

Property grid add remove at runtime.

14 Answers 665 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Hugues
Top achievements
Rank 1
Hugues asked on 23 Feb 2015, 04:49 PM
I can see that whenever a new item is created in the property grid it gets added to the Item collection of the property grid. My question is that is there anyway i can manually add remove item from the Items list. The reason for this is because i want to be able to remove non top level items in the list. For example, i might have an expandable object which i want to remove a single component from the expandable part and have the property grid update properly. Right now there is no way to do that because the Items collection of the property grid is ReadOnly.

14 Answers, 1 is accepted

Sort by
0
Hugues
Top achievements
Rank 1
answered on 23 Feb 2015, 04:51 PM
Also i forgot to mention. I know that the property grid can be rebuild through the propertystore, but i have too many items in the list and that would be way to slow. I do not want to rebuild the whole property grid whenever i remove a single item from it. So i hope there is a better solution.

Thanks.
0
Dimitar
Telerik team
answered on 26 Feb 2015, 12:25 PM
Hello Hugues,

Thank you for writing.

Each item has Visible property which can be used to show or hide the item at run time:
private void radButton1_Click(object sender, EventArgs e)
{
    radPropertyGrid1.Items["Text"].Visible = false;
}

Please let me know if there is something else I can help you with. 
 
Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Hugues
Top achievements
Rank 1
answered on 26 Feb 2015, 04:12 PM
I know about the Visible. But the item is still part of the Item collection. What i wanted to know if there is a way to completely remove it from the collection. My problem with the solution you provide as i start hiding things and the end user add more item. The Collection will just keep growing. I want to  be able to remove it from the collection.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 03 Mar 2015, 10:02 AM
Hello Hugues,

Thank you for writing.

In order to remove items in RadPropertyGrid, you can use the RadPropertyStore.Remove and RadPropertyStore.RemoveAt methods. However, this approach requires populating your data in a RadPropertyStore. If you use a custom object, note that RadPropertyGrid extracts all of its properties and in order to remove a certain property you need to hide it as my colleague Dimitar suggested.

I hope this information helps. Should you have further questions, I would be glad to help.
 
Regards,
Dess
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Hugues
Top achievements
Rank 1
answered on 04 Mar 2015, 04:28 PM
I understand that i can delete top level nodes. But i am using CustomProperties where child nodes are not added through the property store but through Expandable Property. I can access the top level nodes find in the property store, but when it comes to any of the expandable properties, the only option is to call Visible=false. This is not a solution. I Want to remove the expandable node without having to remove the parent node itself. Is that possible or not. Stop giving me the run around.
0
Hugues
Top achievements
Rank 1
answered on 04 Mar 2015, 08:24 PM
I have attached a screenshot of the issue.If you look inside the L1 node i have Fx modifier and Media File. I can access teh L1 and remove it fine. But there is no way to access the Fx modifier and Media File from the propertystore. The only one i can access them is through the Item list of PropertyGrid which is fine. But it is read only and i cannot remove them.
0
Hugues
Top achievements
Rank 1
answered on 04 Mar 2015, 08:27 PM
I have attached a screenshot of the issue.If you look inside the L1 node
i have Fx modifier and Media File. I can access teh L1 and remove it
fine. But there is no way to access the Fx modifier and Media File from
the propertystore. The only one i can access them is through the Item
list of PropertyGrid which is fine. But it is read only and i cannot
remove them.
0
Dimitar
Telerik team
answered on 09 Mar 2015, 11:45 AM
Hi Hugues,

Thank you for writing back.

You cannot edit the Items collection directly, it is populated depending on the selected object properties and represents a list of these properties, and since you cannot change the object properties count at runtime you should not be able to change the collection as well. Nevertheless you can easily show or hide the underlying properties of each item. You can access them by using the GridItems property: 
private void radButton1_Click(object sender, EventArgs e)
{
    radPropertyGrid1.Items[1].GridItems[2].Visible = false;    
}

Another solution would be to use the Browsable attribute directly in your custom objects.

I hope this will be useful. 

Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Suraj
Top achievements
Rank 1
answered on 01 Dec 2016, 09:34 AM

Hi

Can I know how to add element in the property grid

0
Dimitar
Telerik team
answered on 01 Dec 2016, 11:01 AM
Hello Suraj,

The following article shows how you can add items:  RadPropertyStore - adding custom properties.

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

Regards,
Dimitar
Telerik by Progress
Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
0
Suraj
Top achievements
Rank 1
answered on 01 Dec 2016, 11:36 AM

Hello Dimitar,

I have already few properties in RadPropertyGrid maybe they are stored from database table so if I am supposed to add new property then is it necessary to add it in database table because I have added property as shown in link and it is not showing up in GridView. So please help me.

0
Dimitar
Telerik team
answered on 02 Dec 2016, 11:25 AM
Hi Suraj,

These are two different approaches. If you are setting the SelctedObejct property to your custom business object you should add the property to this object. The property store gives you the ability to add properties manually, however, all properties must be added to the PropertyStore object and you should use the PropertyStore object as SelectedObject.

I hope this helps.

Regards,
Dimitar
Telerik by Progress
Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
0
Suraj
Top achievements
Rank 1
answered on 05 Dec 2016, 06:09 AM

Hello Dimitar,

Can I know how to set property values. Suppose there is Color property so how to assign values to it so that when I change its values, its behavior should change accordingly. Like if I change color of series from blue to red how actually color of series is changing.

 

Thanks and Regards,

Suraj

0
Dimitar
Telerik team
answered on 05 Dec 2016, 01:08 PM
Hi Suraj,

The BackColor property in the series is a dependency property which will trigger layout update:
What is your specific case? What do you need to update in this case? Generally, your business object must implement the INotifyPropertyChanged interface. 

I hope this information is useful. Let me know if you need further assistance.

Regards,
Dimitar
Telerik by Progress
Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
Tags
PropertyGrid
Asked by
Hugues
Top achievements
Rank 1
Answers by
Hugues
Top achievements
Rank 1
Dimitar
Telerik team
Dess | Tech Support Engineer, Principal
Telerik team
Suraj
Top achievements
Rank 1
Share this question
or