简体   繁体   中英

How can I read the next DataGridView row?

How can I make this read the DataGridView and SetAttribute? I have been doing this:

(string)dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[0].Value)

to read the first row, but I need to read 0, and then the next row (1, after first second etc)

I have looked at this question: DataGridView navigating to next row

But I don't know how to write it.

This is my code to read now:

webBrowser1.Document.GetElementById("pass").SetAttribute("value", (string)dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[0].Value);

use a for loop to go through all the rows one by one

for(int i=0;i<datagrid.Rows.Count;i++){
    val=datagrid[0,i].Value.Tostring();   // 0 is column no
}

or a while by manually incrementing row count..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM