datagridview sum of cells value and formatting

Joined
Nov 1, 2005
Messages
1
Reaction score
0
Hi @ all :)

This is my first post and im happy to be here. Nice Forum, great works at all.

Here is my first problem:

I've a datagridview that retrieve data from a database.I can do all i need, mean update, delete, insert and works well.

Only problem is a column of datagridview wich have an expression:

myDataSet.Tables["myTables].Columns["totalColumn"].Expression = "column1+column2+column3+....."

And this formula works fine only if i have NO EMPTY cells.

For examples:


Column1 Column2 TotalColumn
1______ 24____ _________25

1______(empty)______ (in this case total still empty)

Any suggest?


Second Problem_

The data in database are all decimal.
And they are shown well when i load the form and populate datagridview, for example:

1,00 5,75 11,45

Now, i need that when user insert a value in a cell, if he press the "." the cell in auto must replace it with the ",".

Someone suggest me of set this thing from control panel\international option, but i would like realize by code.

Im trying something like that:
Code:
         void dataGridView1_KeyPress(object sender,KeyPressEventArgs e)
         {
	                  if (e.KeyChar == '.')
	                {
		                     e.KeyChar.ToString().Replace('.', ',');
	                 }
         }
But doesnt work.

Thx in advance.

Raoul.
 
Last edited:
Back
Top