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

RESET COLUMN FORMAT AFTER DATA BINDING

Thread ID:

Created:

Updated:

Platform:

Replies:

144692 May 17,2019 02:00 PM UTC May 20,2019 11:51 AM UTC WinForms 1
loading
Tags: SfDataGrid
Deepak
Asked On May 17, 2019 02:05 PM UTC

Dear Sir,

1. How to Set Numeric Column Format in SFDATAGRid after binding the data.
I have one Column in Decimal format which want to convert it to Integer(Numeric) Format. Please reply me at the earliest.

2. In SFDATAGRID, how to change the column format from text to dropdown list after data binding ?

Please send me code for the same

Thanks
Deepak

Jagadeesan Pichaimuthu [Syncfusion]
Replied On May 20, 2019 11:51 AM UTC

Hi Deepak, 
  
Thanks for using Syncfusion products. 
  
Query 
Solution 
I have one Column in Decimal format which want to convert it to Integer(Numeric) Format. Please reply me at the earliest. 
If you want to change the decimal format of the numeric column after assigning the datasource, you can use the NumberFormatInfo property of the numeric column. Refer to the following code snippet, 
  
Code Snippet: 
var decimalColumn = this.sfDataGrid1.Columns["UnitPrice"asGridNumericColumn; 
  
//Set the decimal digits as zero to display the numeric values. 
decimalColumn.NumberFormatInfo = newSystem.Globalization.NumberFormatInfo() { NumberDecimalDigits = 0 }; 
In SFDATAGRID, how to change the column format from text to dropdown list after data binding ? 
If you want to change the text column as combobox column after binding the datasource, you need to remove the existing text column from the Columns collection and add it as the ComboBox column. Refer to the following code snippet, 
  
Code Snippet: 
List<string> countries = new List<string>(); 
countries.Add("Austria"); 
countries.Add("Canada"); 
countries.Add("Brazil"); 
countries.Add("Argentina"); 
  
var columnIndex =this.sfDataGrid1.Columns.IndexOf(this.sfDataGrid1.Columns["ShipCountry"]); 
//Remove the existing text column in the given index. 
this.sfDataGrid1.Columns.RemoveAt(columnIndex); 
  
//Insert the combo box column at the given index. 
this.sfDataGrid1.Columns.Insert(columnIndex, new GridComboBoxColumn() { MappingName = "ShipCountry", DataSource = countries }); 
  
 
Let us know whether this helps also if you need any further assistance on this. 
  
Regards, 
Jagadeesan

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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