We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

how to set propertygrid readonly?

Hi, I want to set my propertygrid control readonly or editable depending on some condition.
for example, in this page, the same propertygrid will be readonly, in another page, the same propertygrid will be editable, is that possible?

9 Replies

KP Karuppasamy P Syncfusion Team July 10, 2013 06:38 AM UTC

Hi Shenghao,

Sorry for the delay caused.

Kindly find the sample below.

In the sample, we are getting the property using VisualUtils in the ButtonClick event. Hence by Enabling/Disabling the property, you can set the 'readonly' accesses.

Please let us know if you have any other queries.

Regards,
Karuppasamy P


PropertyGridControlSample_a248cefb.zip


MF Michelle Fowler October 10, 2013 10:05 PM UTC

When I set PropertyGrid.IsEnabled = False, the scroll bar and expanders no longer work. I want it to be displayed in a true read-only mode, where it is completely interactive, but none of the editors allow changing of values. How can I do that?


MF Michelle Fowler October 11, 2013 02:45 PM UTC

I added the attribute ReadOnly(true) to those properties that have a non-private setter but should not be changed by the user.

Example:

        [ReadOnly(true)]
        public double Multiplier { get; set; }



JR Jegan Raj M Syncfusion Team October 21, 2013 04:16 AM UTC

Hi Michelle,

Thanks for your interest in Syncfusion products.

We have created sample based on your request in which the property 'Multiplier' is set as ready only property. By clicking the Button all the properties are set to 'IsEnabled=False" and the scroll viewer will work.

Please let us know if you need further assistance.

Regards,
Jegan Raj M


PropertyGridSample_e0d389f3.zip


KN Krzysztof Nowacki December 18, 2014 03:39 PM UTC

Hi,

When I'm trying to download the second sample, I get access denied error.


DM Duane McKinney December 23, 2016 07:26 PM UTC

I know this is old, but it was the first search result.  

This is a very simple solution that worked for me.  By setting the setter to internal access, it doesn't allow the PropertyGrid control to modify it.  In a more complex project you'll have to go with a more complex solution.
public MyProperty State { getinternal set; }


KJ Keerthana Jegannathan Syncfusion Team December 27, 2016 04:53 AM UTC

  
Hi Duane, 
Thank you for your suggestion. 

As you have mentioned, this will work for simple solution and you can use the same as you suggested.

Regards,
 
Keerthana J 



FS Fernando Salvador replied to shenghao.wu February 25, 2018 05:54 PM UTC

Hi, I want to set my propertygrid control readonly or editable depending on some condition.
for example, in this page, the same propertygrid will be readonly, in another page, the same propertygrid will be editable, is that possible?

.


KJ Keerthana Jegannathan Syncfusion Team February 26, 2018 10:09 AM UTC

Hi Fernando, 
 
Thanks for your update. 
 
Have you tried the setting of property setter as internal one which makes the properties in the PropertyGrid as ReadOnly? Or else, can you share some additional information about your requirement? That helps us to provide and analyze solution at earliest. 
 
Regards, 
 
Keerthana J 


Loader.
Live Chat Icon For mobile
Up arrow icon