hi all
how to place a numeric value (for example 10000000) ,and the value displayed
automatically in datagridview as 10.000.000.
how to give cell automatic formating.the value is coming from database.
regard
denny
Datagridview cell format
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Nainil148 reputationPosted Feb 19, 2010, 6:43 AM EST
To achieve this, you should subscribe to the DataGridView's CellFormating event. In the DataGridView_CellFormating() function, use the e.ColumnIndex property to check for the integer column for whcih you want the format change. Assuming that you want to change the format of the second column which has numeric values (something like 10000000), the code should be as follows:
if (e.ColumnIndex == 1)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");
Thread.CurrentThread.CurrentCulture.NumberFormat.NumberGroupSeparator = ".";
e.Value = Convert.ToInt32(e.Value).ToString("N0");
}
Doing above should provide the desired format (like 10.000.000). Hope this helps.