473,385 Members | 1,876 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,385 software developers and data experts.

Runtime value to Attribute

Hello!

I want to write -

[Persistent, ReadOnly(form.IsFixedValue)]
public double CycleTime
{
get { return cycletime; }
}

i.e. CycleTime should be readonly or otherwise depending on the value
of form.IsFixedValue (IsFixedValue is a property of the form).

But the above code doesn't work (of course). Is there a way to get it
to work the way I want?

TIA,

Pradip

Nov 13 '06 #1
4 1393
I think you need to provide the setter still otherwise it has to be readonly
all the time.

Ciaran O'Donnell

"ca*****@iiitb.ac.in" wrote:
Hello!

I want to write -

[Persistent, ReadOnly(form.IsFixedValue)]
public double CycleTime
{
get { return cycletime; }
}

i.e. CycleTime should be readonly or otherwise depending on the value
of form.IsFixedValue (IsFixedValue is a property of the form).

But the above code doesn't work (of course). Is there a way to get it
to work the way I want?

TIA,

Pradip

Nov 13 '06 #2
Yes, of course. Assuming I have a setter also in place, how can I make
CycleTime readonly or otherwise, depending on form.IsFixedValue?

TIA,
Pradip

Ciaran O''Donnell wrote:
I think you need to provide the setter still otherwise it has to be readonly
all the time.

Ciaran O'Donnell

"ca*****@iiitb.ac.in" wrote:
Hello!

I want to write -

[Persistent, ReadOnly(form.IsFixedValue)]
public double CycleTime
{
get { return cycletime; }
}

i.e. CycleTime should be readonly or otherwise depending on the value
of form.IsFixedValue (IsFixedValue is a property of the form).

But the above code doesn't work (of course). Is there a way to get it
to work the way I want?

TIA,

Pradip
Nov 13 '06 #3
AFAIK you can't without some hacking in the component model and
ICustomTypeDescriptor (and this would only affect things like PropertyGrid -
not compiled code). You can (and should), however, simply make the setter
throw an exception (InvalidOperationException) if it is used incorrectly.

Marc
Nov 13 '06 #4
Hi,

And throwing an exception is usually fine in the designer because it's caught,
and then displayed in a nice little message box :)

--
Dave Sexton

"Marc Gravell" <ma**********@gmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
AFAIK you can't without some hacking in the component model and
ICustomTypeDescriptor (and this would only affect things like PropertyGrid -
not compiled code). You can (and should), however, simply make the setter
throw an exception (InvalidOperationException) if it is used incorrectly.

Marc

Nov 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Geoff Cox | last post by:
Hello, One person to date has received a runtime error message saying "parent.frameleft.location is not an object" with the following code. The code is used to select 2 frames at the same...
0
by: RYoung | last post by:
I have a custom attribute with an "IsPresent" property with get; set accessors. When the attribute is applied to a field of a class, IsPresent will be false by default. At runtime, I'll read in...
5
by: Steven Berkovitz | last post by:
Hi there, I am having a problem where if i add an attribute to a control at runtime the rendered attribute is HTML encoded. For example, on a textbox: textBox.Attributes = "if(x && y)...
7
by: Martin Robins | last post by:
I am currently looking to be able to read information from Active Directory into a data warehouse using a C# solution. I have been able to access the active directory, and I have been able to return...
2
by: Vinayak Kamat | last post by:
Hi, I've got two classes - Entity which will have an array of Child objects in it and Child class. class Entity { public Child Children;
0
by: Matt Adamson | last post by:
Guys, When writing unit tests for our assemblies we'd like to change configuration values at runtime for some tests i.e. to test all code paths are executed. e.g. one method would create a test...
0
by: CK | last post by:
Hi All, I have an asp:CheckBoxList. it is databound to a datatable at runtime; private void chklstStatuses_DataBinding(object sender, EventArgs e) { chklstStatuses.DataSource =...
5
by: Kimmo Laine | last post by:
Hi is there a way to change propertys attribute from the code? Letīs say that i have the following property in my class: public int Count } Is there a way to change the displayname, from...
2
by: Radu | last post by:
Hi, I have a "select" control named "cboSelectScorecardType", defined as <select id="cboSelectScorecardType" size="1" runat="server"> </select> which shows a list of files on my drive. It...
4
by: Walton | last post by:
checkout: (3rd paragraph under 'Remarks' section) http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/name_2.asp from the page: "The NAME attribute...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.