Ticket T1282761
Visible to All Users

Need to update a ribbon DateEdit after a region change

created 6 months ago

Attached is a simple demo that illustrates the issue we have.

We have added a runtime Region setting feature to our WinForms that changes region with:

Code
Globalization.CultureInfo.DefaultThreadCurrentCulture = New Globalization.CultureInfo(regionToSet) Threading.Thread.CurrentThread.CurrentCulture = Globalization.CultureInfo.DefaultThreadCurrentCulture

and it works great for all forms created after the locale change. Open MDI forms don't update but that's not an issue for us.

The problem we have is with a toolbar dateedit. Download and build the attached project with your machine in en-US.

The app comes up like this:
Clipboard-File-1.png

click the little arrow at the right edge of the ribbon group and choose "de-AT" and hit OK
Clipboard-File-2.png

you'll see the Decimal: updates correctly but the Date edit in the ribbon does not:
Clipboard-File-3.png

if you again click the little arrow at the right edge of the ribbon group you see the proper format:
Clipboard-File-4.png

Could you modify my demo project so the DateEdit in the ribbon updates to the current region as expected?

Answers approved by DevExpress Support

created 6 months ago

Hi Quint,

Generally speaking, the .NET localization mechanism is designed to allow you to specify the application's culture when you first initialize the application, and it doesn't facilitate changing the application's culture at runtime as a feature. Consistent with this design, some DevExpress controls may cache the current culture or its formatting settings permanently, until you re-create the control from scratch.

Thus, the only reliable solution to this requirement is to destroy and re-open the form, or better yet, save the selected culture to a custom configuration file and restart the application with this culture.

    Show previous comments (1)
    Norton (DevExpress Support) 6 months ago

      If you strictly need to refresh a specific Ribbon editor, you can use the following workaround:

      Visual Basic
      Dim newEdit = New RepositoryItemDateEdit dateEditItem.Edit = newEdit

        Excellent - that works. I wrote code to manually copy over the settings to the New RepositoryItemDateEdit with code like this:

        Visual Basic
        'make a New RepositoryItemDateEdit w/settings from existing ribbonBarItem.Edit Dim before As DevExpress.XtraEditors.Repository.RepositoryItemDateEdit = editRepo Dim new_RepositoryItemDateEdit As New DevExpress.XtraEditors.Repository.RepositoryItemDateEdit With {.AllowNullInput = before.AllowNullInput, .AutoHeight = before.AutoHeight, .CalendarTimeEditing = before.CalendarTimeEditing, .CalendarView = before.CalendarView, .VistaDisplayMode = before.VistaDisplayMode, .EditMask = before.EditMask, .NullValuePrompt = before.NullValuePrompt, .ShowNullValuePrompt = before.ShowNullValuePrompt, .Name = before.Name} new_RepositoryItemDateEdit.DisplayFormat.FormatString = before.DisplayFormat.FormatString new_RepositoryItemDateEdit.DisplayFormat.FormatType = before.DisplayFormat.FormatType new_RepositoryItemDateEdit.EditFormat.FormatString = before.EditFormat.FormatString new_RepositoryItemDateEdit.EditFormat.FormatType = before.EditFormat.FormatType 'assign new_RepositoryItemDateEdit created under the current locale/region to the ribbonBarItem ribbonBarItem.Edit = new_RepositoryItemDateEdit

        verifying that I didn't miss any settings relevant to my application.

        Is there a better/cleaner way to copy over all the settings from RepositoryItemTextEdit derived repros?

        Norton (DevExpress Support) 6 months ago

          Happy to hear this!

          You can theoretically use the RepositoryItem.Assign method to copy settings from one editor to another. However, it doesn't allow you to specify which settings or groups of settings should be copied, and according to my tests, this method also carries over regional formatting from the source editor (thus negating the solution). So, it's not suitable for this task.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.