GridDateTimeColumn change culture at runtime

Hi,
Is there a way how to update DateTime columns format in sfdatagrid when culture is changed in runtime.
For example I start program with english culture, grid displays DateTime values in format 10/29/2018, when culture is changed in runtime to German I would expect displayed values to be changed to 29.10.2018, but nothing happens. Is there any trick how to do it?

Thank you
Ondřej Svoboda

5 Replies

DY Deivaselvan Y Syncfusion Team November 2, 2018 07:07 AM UTC

Hi Ondrej, 

Thank you for contacting Syncfusion support. 

We have analyzed your query to change DateTimeFormat in display value based on culture changes at runtime and you can achieve your requirement by reloading the controls after changing the culture. This can be done by restarting your application as like below code snippet 

public partial class MainWindow : Window 
{ 
        public MainWindow() 
        { 
            if (!File.Exists("CultureSetting.xml")) 
            { 
                using (XmlWriter writer = XmlWriter.Create("CultureSetting.xml")) 
                { 
                    writer.WriteStartElement("CultureSetting"); 
                    writer.WriteElementString("culture", "en-US"); 
                    writer.WriteEndElement(); 
                    writer.Flush(); 
                } 
            } 
 
            XmlDocument xmlDoc = new XmlDocument(); 
            xmlDoc.Load("CultureSetting.xml"); 
            var value = xmlDoc.DocumentElement.SelectSingleNode("culture").InnerText; 
            xmlDoc.Save("CultureSetting.xml"); 
            Thread.CurrentThread.CurrentCulture = new CultureInfo(value); 
            InitializeComponent(); 
        } 
        
        private void Button_Click(object sender, RoutedEventArgs e) 
        { 
            XmlDocument xmlDoc = new XmlDocument(); 
            xmlDoc.Load("CultureSetting.xml"); 
            xmlDoc.DocumentElement.SelectSingleNode("culture").InnerText = "de"; 
            xmlDoc.Save("CultureSetting.xml"); 
            Application.Current.Shutdown(); 
            System.Windows.Forms.Application.Restart(); 
        } 
} 

Please find sample from the below link and let us know if this helps you 
Sample Link: 
 
Regards, 
Deivaselvan 



OS Ondrej Svoboda November 20, 2018 09:02 AM UTC

Restarting application of course works, but I would like to have it more user friendly = no restart required. Isn't there any other way?
E.g.: for TextBox I simply use FrameworkElement.Language property and format is updated like a charm when culture is changed.


DY Deivaselvan Y Syncfusion Team November 22, 2018 02:58 AM UTC

Hi Ondrej, 

We have analyzed your query to change culture of DataGrid at runtime without restarting the application. Currently we do not have support for this and we are analyzing the feasibility to achieve this requirement by using the FrameworkElement.Language property as like in TextBox.  We will update you with more details on 23rd November,2018. 

Regards, 
Deivaselvan 



SP Shobika Palani Syncfusion Team November 23, 2018 12:36 PM UTC

Hi Ondrej, 

Sorry for the inconvenience caused. 

We are still validating the feasibility to achieve the requirement to change culture at runtime using FrameworkElement.Language property or without restarting the application. We will update you with more details on 26th November,2018 without any further delay. 

Regards, 
Shobika. 



DY Deivaselvan Y Syncfusion Team November 26, 2018 05:18 AM UTC

Hi Ondrej, 

Thanks for your patience. 

Currently we do not have support “to change culture at runtime based on FrameworkElement.Language property”. We have logged this requirement as a feature request in our database. We don’t have any immediate plans to implement this feature. We will let you know once this feature has been implemented in any of our upcoming releases.   
  
Please let us know if you have any other questions.  

Regards,
Deivaselvan 


Loader.
Up arrow icon