Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
int rowskip = 1;
for (int i = rowskip; i <= dataGridView1.Rows.Count - 1; i++)
{
 Double firsttotal = Convert.ToDouble(dataGridView1.Rows[i - 1].Cells[4].Value);
 Double amount = Convert.ToDouble(dataGridView1.Rows[i].Cells[2].Value);
 Double sum = firsttotal + amount;
 dataGridView1.Rows[i].Cells[4].Value = sum.ToString();
}
Posted 4-Jan-13 3:36am
Edited 6-Jan-13 8:25am
Jibesh16.5K
v3
Comments
OriginalGriff at 4-Jan-13 9:43am
   
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
What doesn't work?
What should it do that it isn't, or shouldn't it do that it is?
Use the "Improve question" widget to edit your question and provide better information.
zeshanazam at 4-Jan-13 9:47am
   
can u just tell me to skip selected row to make for loop work ?
shaikh-adil at 4-Jan-13 12:19pm
   
http://www.codeproject.com/Questions/521745/transferingplustheplustextplusfromplusdynamicallyp
can you help me sir please if you can
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Not too sure, but looks like you are talking of something like:
if(! DataGridView1.SelectedRows.Contains(dataGridView1.Rows[i]))
{
  // Do something
}
else
{
  // This row is selected one!
}
Refer: MSDN: DataGridView.SelectedRows Property [^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You have mentioned to skip the selected row in a gridview you can try something like below
int rowskip = 1;
for (int i = rowskip; i <= dataGridView1.Rows.Count - 1; i++)
{
 
 if( dataGridView1.Rows[i].Selected)
 {
   continue;// skip this row if its selected
 }
 
 Double firsttotal = Convert.ToDouble(dataGridView1.Rows[i - 1].Cells[4].Value);
 Double amount = Convert.ToDouble(dataGridView1.Rows[i].Cells[2].Value);
 Double sum = firsttotal + amount;
 dataGridView1.Rows[i].Cells[4].Value = sum.ToString();
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 446
1 OriginalGriff 380
2 Yogesh Kumar Tyagi 304
3 Prakriti Goyal 200
4 Maciej Los 165
0 OriginalGriff 6,472
1 Sergey Alexandrovich Kryukov 5,404
2 Maciej Los 3,434
3 Peter Leow 3,259
4 DamithSL 2,495


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100