Click here to Skip to main content
13,552,932 members
Rate this:
Please Sign up or sign in to vote.
See more:
for (int i =0 ; i <=dataGridView1.Rows.Count-1; i++)
Posted 31-Dec-12 6:09am
Updated 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 31-Dec-12 12:20pm
how is it possible ??
DinoRondelly 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
AnteoDev 31-Dec-12 12:21pm
for (int i =2 ; i <=dataGridView1.Rows.Count-1; i++) ???
zeshanazam 31-Dec-12 12:24pm
and what if i want to skip first row ??
AnteoDev 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++)
Mike-Edmison 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04-2016 | 2.8.180515.1 | Last Updated 31 Dec 2012
Copyright © CodeProject, 1999-2018
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