DataGrid currency column

T

Todd

I've got a DataGrid and I've got a double (currency)
value I'm binding to one of the columns. I'm also
performing cell by cell validation. My problem is that
if the user types a "$" or "," in the bound field, when
the user tabs out, the column sees the field as the
incorrect data type and resets to the old value. I've
tried getting the original value in the column changing
event of the datatable, the grid's cellchanging event,
and the validating event of the textbox (columntextbox)
but it's too late (while tabbing), the value has been
reset.

By the way, I have a column style with format = "$#.00".
It's too bad the grid doesn't handle decimal values that
match the format defined for the column.

So does anyone have any suggestions on this? The only
two things I can think of is to performing masking or
change my datatable column to a string.

Any suggestions would be great.
Todd
 
T

Todd

Dmitriy,

Yeah, I already tried that, same problem.

Todd

-----Original Message-----
Hi Todd,

Try setting the column's format to "C".

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

I've got a DataGrid and I've got a double (currency)
value I'm binding to one of the columns. I'm also
performing cell by cell validation. My problem is that
if the user types a "$" or "," in the bound field, when
the user tabs out, the column sees the field as the
incorrect data type and resets to the old value. I've
tried getting the original value in the column changing
event of the datatable, the grid's cellchanging event,
and the validating event of the textbox (columntextbox)
but it's too late (while tabbing), the value has been
reset.

By the way, I have a column style with format = "$#.00".
It's too bad the grid doesn't handle decimal values that
match the format defined for the column.

So does anyone have any suggestions on this? The only
two things I can think of is to performing masking or
change my datatable column to a string.

Any suggestions would be great.
Todd

.
 
D

Dmitriy Lapshin [C# / .NET MVP]

Then try inheriting from the column and overriding the GetDataColumnInRow
and SetDataColumnInRow methods to implement custom parsing and formatting. I
remember we had to end up with something similar when we were to implement a
"smart" currency editing column.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Todd said:
Dmitriy,

Yeah, I already tried that, same problem.

Todd

-----Original Message-----
Hi Todd,

Try setting the column's format to "C".

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

I've got a DataGrid and I've got a double (currency)
value I'm binding to one of the columns. I'm also
performing cell by cell validation. My problem is that
if the user types a "$" or "," in the bound field, when
the user tabs out, the column sees the field as the
incorrect data type and resets to the old value. I've
tried getting the original value in the column changing
event of the datatable, the grid's cellchanging event,
and the validating event of the textbox (columntextbox)
but it's too late (while tabbing), the value has been
reset.

By the way, I have a column style with format = "$#.00".
It's too bad the grid doesn't handle decimal values that
match the format defined for the column.

So does anyone have any suggestions on this? The only
two things I can think of is to performing masking or
change my datatable column to a string.

Any suggestions would be great.
Todd

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top