Best way to make a bound control readonly?


Author
Message
thegwill
thegwill
StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)
Group: Forum Members
Posts: 16, Visits: 177
I have a business object with a bound field that I display in a form. The field value is populated in code (as a default value for the BO) so the user should not be able to change it although they do need to see it

By defult, when editing, the control becomes enabled. I have remedied this by implementing the EditingStateChanged event on the BO instance on my form and explicitly setting the UI control.Enabled to false

Question is: this works but is there a better way to do this?

Larry Caylor
Larry Caylor
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K
The easy way is to set the controls Enabled property = false and the IgnoreManagedReadOnlyState = true. This will prevent the control from being enabled when the bound object is being added or edited.

-Larry

thegwill
thegwill
StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)
Group: Forum Members
Posts: 16, Visits: 177
Thanks - I'll give it a try
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Larry is correct, you could do that.  Another option is to make the property read-only.  This will prevent the end-user from being able to modify that field as well.  If this is a field that is pulled from the schema, you can assign this through the BO Mapper (it is a check box).  If it is a custom property just assign it as read-only.  The simplest option though may be Larry's suggestion if this is going to be a one time thing.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search