473,549 Members | 2,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting defaultvalue of a property

RR
Hi,

I want to set the defaultvalue of a property in a class.

I know this is possible by the DefaultValue Attribute like this:

public class Test
{
public Test(){}

private string myProperty;

[DefaultValue("T estProperty")]
public string MyProperty
{
get{ return myProperty; }
set{ myProperty = value; }
}
}

I search for a possibility to set the default value for several
languages.

(the defaultvalueatt ribute class is sealed!!).

How can I implement this functionality??

Nov 17 '05 #1
1 1471
"RR" <ro************ @freenet.de> wrote in
news:11******** *************@f 14g2000cwb.goog legroups.com:
Hi,

I want to set the defaultvalue of a property in a class.

I know this is possible by the DefaultValue Attribute like this:

public class Test
{
public Test(){}

private string myProperty;

[DefaultValue("T estProperty")]
public string MyProperty
{
get{ return myProperty; }
set{ myProperty = value; }
}
}

I search for a possibility to set the default value for several
languages.

(the defaultvalueatt ribute class is sealed!!).

How can I implement this functionality??


Robert,

Is this what you mean by "possibilit y to set the default value for
several languages"?

using System.Globaliz ation;

....

private string myProperty = null;
public string MyProperty
{
get
{
// If myProperty has already been set to a value,
// return that value.
if (myProperty != null)
return myProperty;

// Otherwise, return a language-specific default value.
if (CultureInfo.Cu rrentUICulture. Name == "de-DE")
return "German text";
else if (CultureInfo.Cu rrentUICulture. Name == "en-EN")
return "English text";
else if (CultureInfo.Cu rrentUICulture. Name == "jp-JP")
return "Japanese text";
else
return "German text";
}

set { myProperty = value; }
}
--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 17 '05 #2

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

Similar topics

1
1950
by: Mark | last post by:
How do I write the following code to set the default value? Me!xNum.DefaultValue = Me!XCurrency.DefaultValue = Me!XDate.DefaultValue = Me!XString.DefaultValue = Can I just put all the lines of code in the Form's AfterUpdate event? Thanks!
10
2729
by: MLH | last post by:
I have an A97 table with a Yes/No field named TowJob and a form bound to that table. The TowJob control on the form is bound to the same field. It is an option group with Yes and No bttns valued at -1 and 0 respectively. Unless I specifically set the table field's defaultvalue to Null, the form comes up with an automatic value of 0 in the...
18
18328
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on a remote update of tables and fields and can't find enough information on these things. Also, how do you index a field in code?
2
11440
by: timtos | last post by:
I want to set a color property of a user control by default. I am doing it like this: .... DefaultValue(typeof(System.Drawing.Color), "Blue"), .... The compiler likes it but my program ignores it! I´ve also tried other things like:
7
20754
by: charliewest | last post by:
Using .Net CF, i have created a 2 dimension ArrayList, and "binded" this list to a ComboBox control using the "DataSource" property. I have set the DisplaySource and ValueMember properties as well. The control populates well, both the display values, and selected values. However, when i try to "set" the SelectedValue or SelectedIndex...
1
1043
by: Cesar Ronchese | last post by:
Hi all. I need to set a default value to my UserControl, but I'm getting a error when trying reset the value via PropertyGrid on the host IDE: "Object type cannot be converted to target type". The value I'm wanting to set came from a enum value. See the code sample: <DefaultValue(NavigationDirectionEnum.Down)> _
6
2511
by: MLH | last post by:
I have a form named frmVehicleEntryForm. It has a 3-tab tab control. On the 2nd tab page, there's a textbox named VehicleLocationName whose default value setting is =DLookUp("","tblAdmin","=Forms!frmVehicleEntryForm!TowCoDropDownBox") The criteria of the DLookUp points to a control on tab page 1. If, after choosing a company in...
5
8319
by: =?Utf-8?B?bXVzb3NkZXY=?= | last post by:
Hi guys I have the following AccessDataSource control on my page.. <asp:AccessDataSource ID="adsAllStories" runat="server" DataFile="~/App_Data/Stories.mdb" SelectCommand="SELECT StoryID, StoryTitle FROM Stories WHERE StoryTitle LIKE '?%' ORDER BY StoryID DESC"> <SelectParameters> <asp:Parameter Type="char" DefaultValue="A"...
3
8431
by: Johnny Jörgensen | last post by:
Does anybody know how to correctly specify the defaultvalue attribute for a property whose type is an enum. Example: Public Enum TestValues Value1=1 Value2=2 End Enum
0
7450
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7957
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1941
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.