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
zakri ghazalli
NA
1
0
how to sum the integers in the i,j cells in data grid view
May 14 2009 4:44 PM
dear sir,
I have 2 problems that bothering me too much.
1. firstly, how to sum the integers in the cells from the cells of datagridview[0,0]. value to datagridview [jcols,irows].value.
2. secondly, how to multiply the integers in the cell of datagridview[0,0] to datagridview[jcols,irows].value
I paste my codes in here....
please someone help me...
public void acces1()
{
dataGridView2.Columns.Clear();
for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++)
{
string aa;
aa = Convert.ToString(dataGridView1.Rows[i].Cells[1].Value);
dataGridView2.Columns.Add(aa, aa);
dataGridView2.Rows.Add(aa);
}
foreach (DataGridViewRow k in this.dataGridView2.Rows)
{
k.HeaderCell.Value = dataGridView2.Rows[k.Index].Cells[0].Value;
dataGridView2.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
}
public void calc1()
{
int a, b, c;
int l = dataGridView2.Rows.Count - 1;
for (int i = 0; i <= dataGridView2.RowCount - 1;i++ )
{
for (a = 0; a <= dataGridView2.ColumnCount - 2; a++)
{
if (dataGridView2.Rows[i].Index != -1)
{
b = 0;
b= Convert.ToInt32(dataGridView2.Rows[i].Cells[0].Value.ToString());
c = Convert.ToInt32(dataGridView2.Rows[l].Cells[0].Value.ToString());
c = c + b;
dataGridView2.Rows[l].Cells[0].Value =c;
}
else
{
MessageBox.Show("huh!Please Tell me!");
}
}
Reply
Answers (
1
)
How to login programically
How to look for specific items from database