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. Image for the cookie policy date

Culture specific setting in the Grid

I am developing an app that needs to be culture independent. As a test I set the decimal delimeter to be "," instead of ".". The grid appears to be ingoring this setting and continues to take "." as a decimal value, but when the value is redisplayed it is displayed with a comma and not the decimal that was originally typed. I am setting the TableStyle.CultureInfo for the grid that I am creating, and I have verified that the cell that I am changing contains the correct CultureInfo. Any suggestions???

9 Replies

AD Administrator Syncfusion Team December 12, 2003 02:41 PM UTC

The style culture only affects the display of values. If does not force keyboard input to be treated in any particular manner. But if you set Application.CurrentCulture to the desired culture, I think this will make everything work consistently. Will this work for you?


KH Kerry Huguet December 12, 2003 03:50 PM UTC

Clay, I don''t think that I was clear enough about the real problem that is occuring. To Clarify: I am changing the regional settings of windows for English, to make the decimal symbol "," instead of ".". The Application.CurrentCulture is being set to the correct culture that contains these settings. When a "," is typed into a cell textbox the comma is ignored altother when the value is pulled from the CellValue of the cell. EX: 123,55 now becomes 12355. Thanks for your help, Kerry


AD Administrator Syncfusion Team December 12, 2003 10:26 PM UTC

If I drop a GridControl on a form, and add teh code below to formload, I see 123,45 when I type 123,45. If I uncomment the Format line, I see 123,450. Will something like this work for you?
private void Form1_Load(object sender, System.EventArgs e)
{
	CultureInfo culture = Application.CurrentCulture.Clone() as CultureInfo;
	culture.NumberFormat.NumberDecimalSeparator = ",";
	culture.NumberFormat.NumberGroupSeparator = ".";
	Application.CurrentCulture = culture;
	this.gridControl1.TableStyle.CultureInfo = Application.CurrentCulture;
	GridStyleInfo style = this.gridControl1.ColStyles[2];
	style.CellValueType = typeof(double);
	//style.Format = "F3";
	style.BackColor = Color.LightGoldenrodYellow;
}


AD Administrator Syncfusion Team December 13, 2003 08:18 PM UTC

Clay, Thanks for the code sample it works fine, BUT.... I think I have pin-pointed the problem that I am having. I am using the Culture.CurrentCulture to get the current culture settings. The problem appears to occur because the properties of the Culture info are not set explicitly. For Example: This code works: private void Form1_Load(object sender, System.EventArgs e) { CultureInfo culture = CultureInfo.CurrentCulture.Clone() as CultureInfo; culture.NumberFormat.NumberDecimalSeparator = culture.NumberFormat.NumberDecimalSeparator; this.gridControl1.TableStyle.CultureInfo = culture; GridStyleInfo style = this.gridControl1.ColStyles[2]; style.CellValueType = typeof(double); //style.Format = "F3"; style.BackColor = Color.LightGoldenrodYellow; } This Code does not: private void Form1_Load(object sender, System.EventArgs e) { CultureInfo culture = CultureInfo.CurrentCulture.Clone() as CultureInfo; //culture.NumberFormat.NumberDecimalSeparator = culture.NumberFormat.NumberDecimalSeparator; this.gridControl1.TableStyle.CultureInfo = culture; GridStyleInfo style = this.gridControl1.ColStyles[2]; style.CellValueType = typeof(double); //style.Format = "F3"; style.BackColor = Color.LightGoldenrodYellow; }


AD Administrator Syncfusion Team December 14, 2003 04:58 PM UTC

I set my regional setting to it-it, and I don''t see a difference between either set of code snippets you posted. Exactly, what steps do you take to see a difference? Also, what version of our library are you using?


AD Administrator Syncfusion Team December 15, 2003 12:23 PM UTC

I am using version 1.6.1 of the grid, and the difference should be in the input of values. The code that does not explicitly set the property of culture info ignores the comma when it is entered as a decimal point.


AD Administrator Syncfusion Team December 15, 2003 12:40 PM UTC

If my regional setting are French, and I have this code in FormLoad in 1.6.1.0, CultureInfo culture = CultureInfo.CurrentCulture.Clone() as CultureInfo; this.gridControl1.TableStyle.CultureInfo = culture; GridStyleInfo style = this.gridControl1.ColStyles[2]; style.CellValueType = typeof(double); style.Format = "F3"; style.BackColor = Color.LightGoldenrodYellow; If I type 1,1 the cell shows 1,100 for me. You do not not see this?


SF Simon Fielke May 12, 2005 02:45 AM UTC

I have set the Global Settings to Portuguese - Portuguese with "." as the group and "," as the decimal separator. When I use the following code: CultureInfo culture = CultureInfo.CurrentCulture.Clone() as CultureInfo; culture.NumberFormat.NumberGroupSeparator = "."; culture.NumberFormat.NumberDecimalSeparator = ","; grdSurveys.TableStyle.CultureInfo = culture; I am unable to enter "." as group separators. Are you able to help me with this? Much appreciated. >If my regional setting are French, and I have this code in FormLoad in 1.6.1.0, > > >CultureInfo culture = CultureInfo.CurrentCulture.Clone() as CultureInfo; >this.gridControl1.TableStyle.CultureInfo = culture; >GridStyleInfo style = this.gridControl1.ColStyles[2]; >style.CellValueType = typeof(double); >style.Format = "F3"; >style.BackColor = Color.LightGoldenrodYellow; > > >If I type 1,1 the cell shows 1,100 for me. You do not not see this?


AD Administrator Syncfusion Team May 12, 2005 09:30 AM UTC

Make sure you also set the CellvalueType and teh Format on the style object for these cells. This code worked for me. CultureInfo culture = CultureInfo.CurrentCulture.Clone() as CultureInfo; culture.NumberFormat.NumberGroupSeparator = "."; culture.NumberFormat.NumberDecimalSeparator = ","; this.gridControl1.TableStyle.CultureInfo = culture; GridStyleInfo style = this.gridControl1.ColStyles[2]; style.CellValueType = typeof(double); style.Format ="#,###.00"; style.BackColor = Color.LightGoldenrodYellow;

Loader.
Live Chat Icon For mobile
Up arrow icon