繁体   English   中英

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

[英]How do I get the cell value from a datagridview using row index and column index in c#?

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

即:

myvalue = dgvList[2nd row][1st column];

尝试这个

myvalue =dgvList.Rows[rowindex].Cells[columnindex].Value.ToString();
dgvList.Rows[INDEX].Cells[INDEX].Value
dgvList[colIndex, rowIndex].Value
var myvalue =dgvList.Rows[columnindex, rowindex].Value;

如何在dgv cell leave事件中显示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()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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