Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET Database and Reporting (http://www.xtremevbtalk.com/-net-database-and-reporting/)
-   -   How to loop each row of datagrid (http://www.xtremevbtalk.com/-net-database-and-reporting/328816-loop-row-datagrid.html)

SwsCheez 10-24-2017 01:56 AM

How to loop each row of datagrid
 
Please help a newb. Here is my code. I am trying to loop each row of a datagrid every little while. I want the row's information to appear in the text boxes for each piece of row. This way I can compare date with an If Then. Here is my code so far. It displays only the top row. Essentially, I want to run an If Then against each row.

Dim v_SelectRow As Integer

For Each row As DataGridViewRow In DtRemindersDataGridView.Rows

TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""
TextBox13.Text = ""
TextBox14.Text = ""

Try

' v_SelectRow = Me.DtRemindersDataGridView.CurrentRow.Index
TextBox9.Text = Me.DtRemindersDataGridView.Item(0, v_SelectRow).Value
TextBox10.Text = Me.DtRemindersDataGridView.Item(1, v_SelectRow).Value
TextBox11.Text = Me.DtRemindersDataGridView.Item(2, v_SelectRow).Value

TextBox12.Text = Me.DtRemindersDataGridView.Item(3, v_SelectRow).Value
TextBox13.Text = Me.DtRemindersDataGridView.Item(4, v_SelectRow).Value
TextBox14.Text = Me.DtRemindersDataGridView.Item(5, v_SelectRow).Value
Catch ex As Exception
End Try

Next row

Daigon Ali 10-30-2017 10:53 AM

Hi,

v_SelectRow is never assigned to the currentrow as it's commented out.
Even so, I'm not sure the current row index would change during your loop.

You could try
Code:

For  v_SelectRow = 0 to dataGridView1.rows.count-1
instead.


All times are GMT -6. The time now is 02:42 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.