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
Shehroz Imran
NA
22
4k
C# datagridview sum two column and subtract with Value.
May 1 2020 3:33 AM
i have datatable with 2 columns,"Debit" & "Credit", and a variable which store my input opening balance. All i want is two get "account balance" by "OpeningBalance-(credit+Debit)".
Note: the debit and credit columns are dynamically as it depends on my date. So how to find opening balance with above mention formula apply on datagrid.
//for column names and table names
dataGridView1.ColumnCount = 4;
dataGridView1.AutoGenerateColumns =
false
;
dataGridView1.Columns[0].HeaderText =
"NewComments"
;
dataGridView1.Columns[0].DataPropertyName =
"Comments"
;
dataGridView1.Columns[1].HeaderText =
"NewDebit_Amount"
;
dataGridView1.Columns[1].DataPropertyName =
"Debit_Amount"
;
dataGridView1.Columns[2].HeaderText =
"NewCredit_Amount"
;
dataGridView1.Columns[2].DataPropertyName =
"Credit_Amount"
;
"dd=datatable name"
for
(
int
i = 0; i < dd.Rows.Count-1; i++)
{
// //dataGridView1.Rows[i].Cells[12].Value = (dataGridView1.Rows[i].Cells[5].Value.ToString()) +
// //(dataGridView1.Rows[4].Cells[2].Value.ToString()).ToString();
dataGridView1.Rows[i].Cells[
"NEWTotalPrice"
].Value = (Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value.ToString())) + (Convert.ToInt32(dataGridView1.Rows[i].Cells[4].Value.ToString()));
}
dataGridView1.DataSource = dd;
But it gives error, datagridview returns null.
Reply
Answers (
4
)
C# WPF How to bind a nested class to nested datagrid
Is there any way where we can get "Ignore" tests from MSTest