473,320 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Datagrid does not accept comma's

Hello,
Here is the scenario:
I have a datagrid on a winform and a datatable is set as its
datasource. I have added DataGridTableStyle in datagrid's TableStyles
property. Some of Gridstyles are numeric (doubles) and I have set their
format to #,0.0000 since I want to display the values to comma seperated
(at thousands) and till four decimal places. User can also edit values
in the grid. So far so good.

The Problem:
Edited cell value reverts back to the previous value when the user
enters a comma formatted value. For example: original value was 52.0000
and user entered 1,000,000. IMO i should be displayed as 1,000,000.0000
but the value reverts back to 52.0000. I have tried to consume
CurrentCellChanged event of datagrid and also RowChanging/ColumnChanging
events.
- CurrentCellChanged event does not give me the new value from the
CurrencyManager.
- RowChanging/ColumnChanging events do not raise at all in the above
mentioned scenario.

Any thoughts/workarounds?

TIA.
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
3 2767
Maqsood,

Are you using DataGridColumnStyles

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor
Nov 17 '05 #2
Hello,
Yes I am using the DataGridColumnStyles (DataGridTextBoxColumn). I have
associated double with the DataGridTextBoxColumn and set its format to
"#,0.0000". Actual problem is that it does not accept formatted input.
It works fine otherwise.

TIA
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #3
Ahmed,

I can do the behaviour you describe when I use the "c" format and don't
delete the currency sign.

With this it goes in my opinion fine.

\\
DataTable dt = new DataTable();
dt.Columns.Add("decimal",Type.GetType("System.Doub le"));
dt.LoadDataRow(new Object[] { 111111.11 }, true);
dataGrid1.DataSource = dt;
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = dt.TableName;
DataGridTextBoxColumn tb = new DataGridTextBoxColumn();
tb.MappingName = "decimal";
tb.Format = "d";
ts.GridColumnStyles.Add(tb);
dataGrid1.TableStyles.Add(ts);
///

I hope this helps,

Cor

"Maqsood Ahmed" <ma***********@gmail.com> schreef in bericht
news:Oa**************@TK2MSFTNGP15.phx.gbl...
Hello,
Yes I am using the DataGridColumnStyles (DataGridTextBoxColumn). I have
associated double with the DataGridTextBoxColumn and set its format to
"#,0.0000". Actual problem is that it does not accept formatted input.
It works fine otherwise.

TIA
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Matthew Wieder | last post by:
Hi - I have a datagrid that has a black header and the rows alternate white and gray. The problem is that until items are added to the grid, the grid appears as a large black rectangle, which is...
5
by: cwbp17 | last post by:
Hi all, Have a datagrid that displays the price column of a table. Went to the Datagrid's Property builder and set the 'Data Formatting expression' for the PRICE column to {0:c}, so that the...
0
by: Jeremiah Adams | last post by:
I am having two issues with the Datagrid and I hope that someone can help me out with them. 1) Printing. I pulled the code for sending the control to a printer off the msdn site. It works for...
1
by: nate axtell | last post by:
In VB .NET I load the contents of an Excel or comma seperated values file into a dataGrid (via a datatable). One of the columns has a comma in the name of the column. So for the comma separated...
4
by: Peter | last post by:
(VS 2003) I have a DataGrid and accept button. My problem is when a user starts to edit one of the values in the grid and does not either press Enter or move of the current cell and presses the...
7
by: rn5a | last post by:
The first column of a DataGrid has a CheckBox for all the rows. I want that when users check a CheckBox, the BackColor of that entire row in the DataGrid should change to a different color. To...
0
by: rn5a | last post by:
All the rows in a DataGrid are accompanied by a CheckBox. When a user checks the rows & clicks a Button, the checked rows get deleted. For e.g. assume that the DataGrid displays 10 rows. A user...
1
by: hygum | last post by:
I've found a useful script that only accepts numbers and a point, and 3 decimals, in an input. But here in denmark we normally use comma as decimal delimiter in numbers, not the point (.) as in...
3
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.