TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Akemi Chou
NA
13
8.9k
Total SUM of cells in datagridview
Jun 29 2014 4:36 AM
I have two datagrids in my form. The first one already have values and the other one is empty in which what has been selected in the first one will be added into the other one. My problem is while I am adding multiple items with prices * quantity of a product the total amount of it is not correct base on the cell of summation (specifically in Cell[7]). Here's my Code. for more details see the image
http://i57.tinypic.com/scurkm.jpg
private void txtQuantity_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
int quantity = Convert.ToInt32(txtQuantity.Text);
double totalProd = price * quantity;
dr["Total"] = totalProd;
dr["Quantity"] = quantity;
for (int i = 0; i < gridViewProduct_Transac.Rows.Count; i++)
{
sum += Convert.ToDouble(gridViewProduct_Transac.Rows[i].Cells[7].Value);
}
double total = sum;
lblSubtotal.Text = total.ToString("#,##0.##");
lblTotalAmount.Text = total.ToString("#,##0.##");
lblTotal.Text = total.ToString("#,##0.##");
cboSearchBy.Focus();
txtQuantity.Text = "";
gridViewProduct_Transac.DataSource = dt;
}
}
Reply
Answers (
1
)
exchange data between forms ?
'out' keyword in c#