Export (0) Print
Expand All

DataTable.Locale Property

Gets or sets the locale information used to compare strings within the table.

[Visual Basic]
Public Property Locale As CultureInfo
[C#]
public CultureInfo Locale {get; set;}
[C++]
public: __property CultureInfo* get_Locale();
public: __property void set_Locale(CultureInfo*);
[JScript]
public function get Locale() : CultureInfo;
public function set Locale(CultureInfo);

Property Value

A CultureInfo that contains data about the user's machine locale. The default is the DataSet object's CultureInfo (returned by the Locale property) to which the DataTable belongs; if the table doesn't belong to a DataSet, the default is the current system CultureInfo.

Remarks

A CultureInfo represents the software preferences of a particular culture or community.

When used for string comparisons, the CultureInfo affects sorting, comparisons, and filterings.

Example

[Visual Basic, C#, C++] The following example sets the CultureInfo through the Locale and prints the ISO language name.

[Visual Basic] 
Private Sub ChangeCultureInfo(myTable As DataTable)
   ' Print the LCID  of the present CultureInfo.
   Console.WriteLine(myTable.Locale.LCID)
   ' Create a new CultureInfo for the United Kingdom.
   Dim myCultureInfo As CultureInfo = New CultureInfo("en-gb")
   myTable.Locale = myCultureInfo
   ' Print the new LCID.
   Console.WriteLine(myTable.Locale.LCID) 
End Sub

[C#] 
private void ChangeCultureInfo(DataTable myTable){
   // Print the LCID  of the present CultureInfo.
   Console.WriteLine(myTable.Locale.LCID);
   // Create a new CultureInfo for the United Kingdom.
   CultureInfo myCultureInfo = new CultureInfo("en-gb");
   myTable.Locale = myCultureInfo;
   // Print the new LCID.
   Console.WriteLine(myTable.Locale.LCID); 
}

[C++] 
private:
 void ChangeCultureInfo(DataTable* myTable){
    // Print the LCID  of the present CultureInfo.
    Console::WriteLine(myTable->Locale->LCID);
    // Create a new CultureInfo for the United Kingdom.
    CultureInfo* myCultureInfo = new CultureInfo(S"en-gb");
    myTable->Locale = myCultureInfo;
    // Print the new LCID.
    Console::WriteLine(myTable->Locale->LCID); 
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataTable Class | DataTable Members | System.Data Namespace | CultureInfo

Show:
© 2015 Microsoft