473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to set a Property ReadOnly dynamically based on another property value.

Hi,

I have a class with two Properties like HasSubMenu, and SubMenu , object of this class is bound to property grid. The class is given below.

Expand|Select|Wrap|Line Numbers
  1. class test
  2. {
  3.  
  4.     private bool m_HasSubMenu;
  5.     private string m_SubMenu;
  6.  
  7.     [Browsable(true)]
  8.     public bool HasSubMenu
  9.     {
  10.         get { return m_HasSubMenu; }
  11.         set { m_HasSubMenu = value; }
  12.     }
  13.  
  14.  
  15.     [Browsable(true)]
  16.     [ReadOnly(true)]
  17.     public List<Menu> SubMenu
  18.     {
  19.         get { return m_SubMenu; }
  20.         set { m_SubMenu = value; }
  21.     }
  22.  
  23. }
  24.  
This object of this class (initially with HasSubMenu false and an empty SubMenu string ) is bound to a property grid. Now that I have a ReadOnlyAttribute set for SubMenu property this string is read only and user can't edit in the property grid. But what I want is if the user changes the HasSubMenu property to true I want this string to be editable (I mean somehow I want to make this ReadOnly attribute of SubMenu property false.)



I am not able to figure out how should I do this. Any help will be highly appreciated



Thanks and Regrads
Feb 4 '09 #1
1 2117
tlhintoq
3,525 Expert 2GB
Instead of worrying about making your List<> read only, just focus on making the control it is attached to read-only. Its a lot easier since most controls have a property for this.
Feb 5 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Job Lot | last post by:
How can I make a property change value of another property at design time? I have added HighlightRow property to custom DataGrid control. Now I want to assign this property similar to DataGrid’s...
8
by: Able | last post by:
Dear friends In a class I have this property: Private mstr_FirstName As String Public Property FirstName() As String Get
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
3
by: Moe Sizlak | last post by:
Hi There, I am trying to use the to obtain the information from 2 listmenus, if the user makes a selection the page is submitted and then based on the value selected is transfererd to another...
5
by: Dan Iregren | last post by:
Hi, I need to know when a property has ben modified (IsDirty). The most obvious way to solve the problem is perhaps something like the following; Private m_sFirstName As String Private...
1
by: moondaddy | last post by:
I'm writing a winforms app in vb.net 1.1 and want to know if there's a way to dynamically change a property in a business class from readwrite to readonly and back again. The next thing I want to...
2
by: miben | last post by:
I need to set a variable returned by a readonly property in a class by another class. So the only way to set that value is from a specific class and function. Public Sub Main Dim setter As New...
1
by: shapper | last post by:
Hello, I am creating a user control where an Asp.Net control is used. It can be either a button, an image button or a label. I am trying to "expose" the Asp.Net control properties and events...
11
by: Andrus | last post by:
I'm implementing entity object which should populate its properties from database when property is first referenced. In RDL reports I use object properties like MyObject.MyProperty MyObject...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.