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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
NainilPosted Feb 19, 2010, 11:43 AM
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.