[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

foreach not doing last item

Posted on 2011-10-04
4
Medium Priority
?
191 Views
Last Modified: 2013-12-16
This is my foreach statement:            

foreach (DataGridViewRow dataRow in dgv1.Rows)  
            {
                int rowNbr = dataRow.Index;

Open in new window


There are 23 rows in the DGV... it stops after DataRow.Index = 22 (code for index 22 gets executed, 23 does NOT)

Any ideas why?
0
Comment
Question by:rmmarsh
  • 2
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
effes earned 2000 total points
ID: 36912772
The index starts with 0. So if you have 23 rows, the index runs from 0 to 22.
0
 

Author Comment

by:rmmarsh
ID: 36912854
Hmmm... let me cogitate on this for a bit...
0
 

Author Closing Comment

by:rmmarsh
ID: 36913021
Got it!  

Pilot error on my part... but your comment helped immensely...  thank you
0
 
LVL 6

Expert Comment

by:effes
ID: 36913064
You're welcome.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question