Click here to Skip to main content
12,509,148 members (55,688 online)
Rate this:
 
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
Updated 6-Jan-13 8:25am
Jibesh17.4K
v3
Comments
OriginalGriff 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 4-Jan-13 9:47am
   
can u just tell me to skip selected row to make for loop work ?
shaikh-adil 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2016
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