PC Review


Reply
Thread Tools Rate Thread

Defaultvalue

 
 
RedLars
Guest
Posts: n/a
 
      16th Feb 2007
This code set an employee's salary to £20,000 by default. I'd like to
set this at runtime, i.e. let the variable _recommendSalary be the
default value.

public class Employee
{
private string _Name = "";
private int age = 0;
private string _Position = "";
private string _Salary = "";
private string _recommendSalary = "£22,000";
private string[] _SalaryOption = { "£20,000", "£25,000",
"£30,000", "£40,000" };

[DefaultValueAttribute("£20,000")]
public string Salary { ... }
// properties to access member values
}

Been looking at this for a while but unsure which method that would
handle such a property. I have both an EmployeeCollection class that
implements ICustomTypeDescriptor and
EmployeeCollectionPropertyDescriptor that inherets from
PropertyDescriptor.

Appreciate any input.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=
Guest
Posts: n/a
 
      16th Feb 2007
This is not possible as the attribtue is compiled into the metadata for the
assembly and it cannot be modified at runtime.

Is this just to get the property grid value to not be bold when the value
isnt 20K.?

--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com


"RedLars" wrote:

> This code set an employee's salary to £20,000 by default. I'd like to
> set this at runtime, i.e. let the variable _recommendSalary be the
> default value.
>
> public class Employee
> {
> private string _Name = "";
> private int age = 0;
> private string _Position = "";
> private string _Salary = "";
> private string _recommendSalary = "£22,000";
> private string[] _SalaryOption = { "£20,000", "£25,000",
> "£30,000", "£40,000" };
>
> [DefaultValueAttribute("£20,000")]
> public string Salary { ... }
> // properties to access member values
> }
>
> Been looking at this for a while but unsure which method that would
> handle such a property. I have both an EmployeeCollection class that
> implements ICustomTypeDescriptor and
> EmployeeCollectionPropertyDescriptor that inherets from
> PropertyDescriptor.
>
> Appreciate any input.
>
>

 
Reply With Quote
 
RedLars
Guest
Posts: n/a
 
      16th Feb 2007
Thanks for the feedback.

Very surprised by this. I'm about to design a configuration tool which
fits in with the property grid. My aim is to differentiation between a
default value and other values (not wether the text is bold or not).


On 16 Feb, 13:20, Ciaran O''Donnell
<CiaranODonn...@discussions.microsoft.com> wrote:
> This is not possible as the attribtue is compiled into the metadata for the
> assembly and it cannot be modified at runtime.
>
> Is this just to get the property grid value to not be bold when the value
> isnt 20K.?
>
> --
> Ciaran O''Donnellhttp://wannabedeveloper.spaces.live.com
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re:DefaultValue Áº¾µ·æ Microsoft Access 0 7th Jan 2009 09:36 AM
DefaultValue =?Utf-8?B?Sm9uV2F5bg==?= Microsoft Access Queries 1 17th Apr 2007 02:34 PM
DefaultValue = 0 =?Utf-8?B?Q2h1Y2s=?= Microsoft Access Database Table Design 3 18th Apr 2006 09:30 PM
DefaultValue =?Utf-8?B?QWxleA==?= Microsoft Access Form Coding 2 28th Oct 2004 06:19 PM
DefaultValue LucB Microsoft Access Form Coding 4 7th Jun 2004 02:57 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:51 AM.