Click here to Skip to main content
11,438,226 members (56,529 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
 for (int i =0 ; i <=dataGridView1.Rows.Count-1; i++)
Posted 31-Dec-12 7:09am
Edited 31-Dec-12 7:15am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I think what your asking is how to skip the first 2 rows ?

If so just check the value of i before you execute any code in your loop,
  Permalink  
Comments
zeshanazam at 31-Dec-12 12:20pm
   
how is it possible ??
DinoRondelly at 31-Dec-12 12:31pm
   
for (int i =0 ; i <=dataGridView1.Rows.Count-1; i++)
{
if( i > whatever row you wanted to start on)
{
Do whatever you want
}
}
Anteo4Ever at 31-Dec-12 12:21pm
   
for (int i =2 ; i <=dataGridView1.Rows.Count-1; i++) ???
zeshanazam at 31-Dec-12 12:24pm
   
and what if i want to skip first row ??
Anteo4Ever at 31-Dec-12 12:27pm
   
Set a variable before the loop, like this:

int rowsToSkip = 1;
for (int i = rowsToSkip ; i <=dataGridView1.Rows.Count-1; i++)
{
this.DoWork(datagridView1.Rows[i]);
}
wolfcoder75 at 31-Dec-12 12:37pm
   
Like Anteo4Ever said, variable set would probably be best bet to follow, but hear is how that works.

Your list starts at 0,
so the the "i=rowsToSkip" says it will start at 1, which excludes your first line that being 0.

So list of:
0 = wordA
1 = Letter2
2 = ItemC

It will start on line 1 which is "Letter2" which can be done different with while loops which we won't get into.

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



Advertise | Privacy | Mobile
Web03 | 2.8.150506.1 | Last Updated 31 Dec 2012
Copyright © CodeProject, 1999-2015
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