)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to switch between two CultureInfo and vice-versa, dynamically in a WinForms GridControl with the Formula CellType?

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 18, 2019

Switch between two cultureinfo

Refer to the following steps to switch between two CultureInfo.

  1. Pass the current culture name in the CultureInfo class. As, the System.Globalization.CultureInfo() represents information about a specific culture including the names of the culture.
  2. Assign the new CultureInfo to the Grid's CultureInfo.

C#

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
   string culName = "";
   switch (this.comboBox1.SelectedIndex)
   {
      case 0:
              culName = "en-GB";
              break;
      //English united states
      case 1:
              culName = "en-US";
              break;
      //German culture
      case 2:
              culName = "de-DE";
              break;
   }
   //clear the grid
   this.gridControl1.RowCount = 0;
   this.gridControl1.RowCount = 10;
   this.gridControl1.ColCount = 5;
   //Passing the new culture name and setting the CultureInfo
   System.Globalization.CultureInfo ci = null;
   if (culName.Length == 0)
   {
      ci = System.Globalization.CultureInfo.CurrentCulture;
   }
   else
   {
      ci = new System.Globalization.CultureInfo(culName);
   }
   //Assigning the new culture to Grid's CultureInfo
   this.gridControl1.TableStyle.CultureInfo = ci;
   Application.CurrentCulture = ci;
   GridFormulaEngine.ParseDecimalSeparator = Application.CurrentCulture.NumberFormat.NumberDecimalSeparator.ToCharArray()[0];
   GridFormulaEngine.ParseArgumentSeparator = Application.CurrentCulture.TextInfo.ListSeparator.ToCharArray()[0];
   this.label1.Text = "Current Culture for the grid: " + ci.Name;
}

VB

Private Sub comboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim culName As String = ""
   Select Case Me.comboBox1.SelectedIndex
       Case 0
                culName = "en-GB"
       'English united states
       Case 1
                culName = "en-US"
       'German culture
       Case 2
               culName = "de-DE"
       End Select
   'clear the grid
   Me.gridControl1.RowCount = 0
   Me.gridControl1.RowCount = 10
   Me.gridControl1.ColCount = 5
   'Passing the new culture name and setting the CultureInfo
   Dim ci As System.Globalization.CultureInfo = Nothing
   If culName.Length = 0 Then
     ci = System.Globalization.CultureInfo.CurrentCulture
   Else
     ci = New System.Globalization.CultureInfo(culName)
   End If
   'Assigning the new culture to Grid's CultureInfo
   Me.gridControl1.TableStyle.CultureInfo = ci
   Application.CurrentCulture = ci
   GridFormulaEngine.ParseDecimalSeparator = Application.CurrentCulture.NumberFormat.NumberDecimalSeparator.ToCharArray()(0)
   GridFormulaEngine.ParseArgumentSeparator = Application.CurrentCulture.TextInfo.ListSeparator.ToCharArray()(0)
   Me.label1.Text = "Current Culture for the grid: " & ci.Name
End Sub

 

Note:

In German language, the sum of the two variables are separated by the semicolon. Example: Sum(a;b)

 

Samples:

C#: Cultureinfo

VB: Cultureinfo

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
chetan
Aug 14, 2014
how can i down load this source file ? http://help.syncfusion.com/support/samples/kb/Grid.Windows/FormulaCulture/FormulaCultureDynamically.zip Reply
Neelakandan Kannan [Syncfusion]
Aug 14, 2014
Hi Chetan, Regret for the inconvenience caused. we have changed sample location.please refer to it Regards, Neelakandan Reply

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon