Property grid add remove at runtime.

15 posts, 0 answers
  1. Hugues
    Hugues avatar
    54 posts
    Member since:
    Sep 2014

    Posted 23 Feb 2015 Link to this post

    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.
  2. Hugues
    Hugues avatar
    54 posts
    Member since:
    Sep 2014

    Posted 23 Feb 2015 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dimitar
    Admin
    Dimitar avatar
    1411 posts

    Posted 26 Feb 2015 Link to this post

    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.

     
  5. Hugues
    Hugues avatar
    54 posts
    Member since:
    Sep 2014

    Posted 26 Feb 2015 in reply to Dimitar Link to this post

    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.
  6. Dess
    Admin
    Dess avatar
    1607 posts

    Posted 03 Mar 2015 Link to this post

    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.

     
  7. Hugues
    Hugues avatar
    54 posts
    Member since:
    Sep 2014

    Posted 04 Mar 2015 in reply to Dess Link to this post

    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.
  8. Hugues
    Hugues avatar
    54 posts
    Member since:
    Sep 2014

    Posted 04 Mar 2015 Link to this post

    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.
  9. Hugues
    Hugues avatar
    54 posts
    Member since:
    Sep 2014

    Posted 04 Mar 2015 Link to this post

    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.
  10. Dimitar
    Admin
    Dimitar avatar
    1411 posts

    Posted 09 Mar 2015 Link to this post

    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.

     
  11. Suraj
    Suraj avatar
    3 posts
    Member since:
    Dec 2016

    Posted 5 days and 5 hours ago in reply to Dimitar Link to this post

    Hi

    Can I know how to add element in the property grid

  12. Dimitar
    Admin
    Dimitar avatar
    1411 posts

    Posted 5 days and 4 hours ago Link to this post

    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.
  13. Suraj
    Suraj avatar
    3 posts
    Member since:
    Dec 2016

    Posted 5 days and 3 hours ago in reply to Dimitar Link to this post

    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.

  14. Dimitar
    Admin
    Dimitar avatar
    1411 posts

    Posted 4 days and 3 hours ago Link to this post

    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.
  15. Suraj
    Suraj avatar
    3 posts
    Member since:
    Dec 2016

    Posted 1 day and 9 hours ago in reply to Dimitar Link to this post

    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

  16. Dimitar
    Admin
    Dimitar avatar
    1411 posts

    Posted 1 day and 2 hours ago Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready