Click here to Skip to main content
11,721,053 members (83,895 online)
Rate this: bad
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 6:09am
Edited 31-Dec-12 6:15am

1 solution

Rate this: bad
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,
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++)
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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 500
1 OriginalGriff 334
2 Mika Wendelius 160
3 F-ES Sitecore 140
4 Maciej Los 80
0 Sergey Alexandrovich Kryukov 2,199
1 OriginalGriff 959
2 F-ES Sitecore 640
3 Maciej Los 609
4 Richard MacCutchan 540

Advertise | Privacy | Mobile
Web03 | 2.8.150901.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