DateTimePicker and language

Hi everybody

first: thank for your help

second:

i have a DateTimePicker with a custom format like dd MMM yyyy. it display 13 dec. 2006. it's right

my regional settings is fr, for all of my application, it' right too

but for date, i want an english format: "dec" instead of "dec"

how can i do it

is there a method or value for define them

thank's everybody for your help




Answer this question

DateTimePicker and language

  • Dominik Mauchle

    my regional settings are english.

    my .net framework is in french.

    my windows is in english.

    but my dateTimePicker is also in french



  • John Hennesey

    Gpg,
    To avoid this behavior, trap the data before it is displayed in the control, and then change the data so that it is valid. 
    
    For example, the following code traps the DBNull value and changes the value to a date value of January 1, 1800.

    This code uses event handlers with the DateTimePicker control to monitor when the value changes. If the value is null, the value is changed to January 1, 1800.

     

    Private Sub Button1_Click(ByVal sender As System.Object, _

    ByVal e As System.EventArgs) Handles Button1.Click

    Dim MyDataSet As New DataSet()

    Dim MyTable As New Data.DataTable("dsTable")

    Dim MyColumn As New DataColumn("HireDate")

    MyDataSet.Tables.Add(MyTable)

    MyColumn.AllowDBNull = True

    MyColumn.DataType = GetType(System.DateTime)

    MyTable.Columns.Add(MyColumn)

    Dim MyData(0) As Object

    MyTable.Rows.Add(MyData)

    Dim MyBinding As New Binding("Value", MyDataSet.Tables("dsTable"), "HireDate")

    AddHandler MyBinding.Format, AddressOf DTFormatter

    AddHandler MyBinding.Parse, AddressOf DTParser

    DateTimePicker1.DataBindings.Add(MyBinding)

    End Sub

    Private Sub DTFormatter(ByVal sender As Object, ByVal e As ConvertEventArgs)

    Dim b As Binding = CType(sender, Binding)

    If Not e.DesiredType Is GetType(DateTime) Then

    Return

    End If

    If e.value.GetType Is GetType(System.DBNull) Then

    e.value = CType("1/1/1800", System.DateTime)

    End If

    End Sub

    Private Sub DTParser(ByVal sender As Object, ByVal e As ConvertEventArgs)

    If Not e.DesiredType Is GetType(DateTime) Then

    Return

    End If

    If Not e.value.GetType Is GetType(DateTime) Then

    Return

    End If

    Dim value As String = CType(e.Value, String)

    If value.Equals("1/1/1800") Then

    e.value = System.DBNull.value

    End If

    End Sub



  • bola shokry

    Regional/CUltural formats are taken care of in the System.Globalization Namespace for date and time see:

    Public Overridable Property DateTimeFormat() As System.Globalization.DateTimeFormatInfo

    Member of: System.Globalization.CultureInfo

    Summary:

    Gets or sets a System.Globalization.DateTimeFormatInfo that defines the culturally appropriate format of displaying dates and times.

    Return Values:

    A System.Globalization.DateTimeFormatInfo that defines the culturally appropriate format of displaying dates and times.



  • Vadish

    DateTimePicker Control not support locales other than the user's default.

    http://www.microsoft.com/middleeast/msdn/ArabicCalendar.aspx#MCAL


    Infragistics Control Supported.

    huk~


  • XuMiX

    - System.Globalization.CultureInfo.CurrentCulture {System.Globalization.CultureInfo} System.Globalization.CultureInfo
    - MonthNames {Length=13} String()
    (0) "January" String
    (1) "February" String
    (2) "March" String
    (3) "April" String
    (4) "May" String
    (5) "June" String
    (6) "July" String
    (7) "August" String
    (8) "September" String
    (9) "October" String
    (10) "November" String
    (11) "December" String
    (12) "" String
    DisplayName "English (United Kingdom)" String
    EnglishName "English (United Kingdom)" String
    IetfLanguageTag "en-GB" String
    ThreeLetterWindowsLanguageName "ENG" String
    TwoLetterISOLanguageName "en" String

    windows' Regional settings are set to english: all is ok

    windows' Regional settings are set to french: month name are displayed in french

    but in french or in english, System.Globalization.CultureInfo.CurrentCulture ARE THE SAME (and system.Globalization.DateTimeFormatInfo.CurrentInfo are the same too)

    but in each case,



  • DavidTempeArizona

    Gpg,

    In DateTimePicker control, the Format property sets the DateTimePickerFormat of the control. The default date Format is DateTimePickerFormat.Long. If the Format property is set to DateTimePeckerFormat.Custom, you can create your own format style by setting the CustomFormat property and building a custom format string. The custom format string can be a combination of custom field characters and other literal characters.

    I suggest you to read the following two points:

    1. DateTimePicker.CustomFormat Property in MSDN as follows:

    http://msdn2.microsoft.com/en-us/library/system.windows.forms.datetimepicker.customformat.aspx

    2. Custom DateTime format strings

    http://msdn2.microsoft.com/en-us/library/8kb3ddd4.aspx



  • COLLECTOR

    thank's for u're idea

    it's a solution, but not the best for me. u're solution translate only the result of dtp selection, not dtp

    exemple

    01/04/2006 = fr: "01 avr 2006" us: "01 apr 2006". this result is correct, it's translated

    but the dtp show, when it's expensed, value "Avril" instead of "April"

    can i translate dtp value

    thank's for u're help and u're time



  • DateTimePicker and language