Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
i have a data grid view with 1 column & several rows
my code is like :

VB
DataGridView1.DataSource = Serials1DataTable.GetData
For Each row in DataGridView1.DataSource
MsgBox('Each Rows Value')
Next

i have tried to use
VB
DataGridView1.CurrentCell.Value.ToString
but i get 3 msgbox with 1 value (first value)
i want to get 3 msgboxes with 3 values

can anyone help me ?
Posted

1 solution

C#
foreach(DataGridItem dataGridItem in DataGridView1.Items){
       MsgBox('Value is'+dataGridItem.Cells[0].Text)
}
 
Share this answer
 
v2
Comments
KababChi 3-Jul-13 1:55am    
generates error
Naz_Firdouse 3-Jul-13 2:05am    
what error you are getting?
KababChi 3-Jul-13 2:10am    
4 errors
1. ')' expected
2. 'DataGridItem' is not declared. It may be inaccessible due to its protection level.
3. 'Items' is not a member of 'System.Windows.Forms.DataGridView'
4. Syntax Error.

i am working with visual basic 10 - oledb databases
Naz_Firdouse 3-Jul-13 2:22am    
Check this

For i As Integer = 0 To DataGridView1.Rows.Count - 1
MsgBox( DataGridView1.Rows(i).Cells("YourColumnName").Value );
Next
KababChi 3-Jul-13 2:33am    
"YourCellName" must be replaced with ColumnName
tanx Naz

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900