如何使用c#中的行索引和列索引从datagridview获取单元格值?

如何使用c#中的行索引和列索引从datagridview获取单元格值?,c#,datagridview,C#,Datagridview,我有一个datagridviewdgvList。。然后,我想获取特定行和列的单元格值,而不使用selectedRows属性 即: 试试这个 myvalue =dgvList.Rows[rowindex].Cells[columnindex].Value.ToString(); 如何在dgv单元离开事件中在dvg中显示数据库值 str = "select pprice from product_tbl2 where name='" & Me.DataGridView1.CurrentRo

我有一个datagridviewdgvList。。然后,我想获取特定行和列的单元格值,而不使用selectedRows属性

即:

试试这个

myvalue =dgvList.Rows[rowindex].Cells[columnindex].Value.ToString();

如何在dgv单元离开事件中在dvg中显示数据库值

str = "select pprice from product_tbl2 where name='" & Me.DataGridView1.CurrentRow.Cells(1).Value.ToString() & "'"
                cmd.CommandText = str
                MsgBox(cmd.CommandText)
                cmd.Connection = cn
                da = New SqlDataAdapter(cmd.CommandText, cn)
                dt = New DataTable()
                da.Fill(dt)
                dvg.currentrows.cell(3) = dt.Rows(0)(0).ToString()

行[yourRow].Cells[yourCell]?你的问题中也缺少它
myvalue =dgvList.Rows[rowindex].Cells[columnindex].Value.ToString();
dgvList[colIndex, rowIndex].Value
str = "select pprice from product_tbl2 where name='" & Me.DataGridView1.CurrentRow.Cells(1).Value.ToString() & "'"
                cmd.CommandText = str
                MsgBox(cmd.CommandText)
                cmd.Connection = cn
                da = New SqlDataAdapter(cmd.CommandText, cn)
                dt = New DataTable()
                da.Fill(dt)
                dvg.currentrows.cell(3) = dt.Rows(0)(0).ToString()
var myvalue =dgvList.Rows[columnindex, rowindex].Value;