10

I have a datagridview dgvList.. Then I want to get the cell value of a particular row and column, without using the selectedRows property.

ie:

myvalue = dgvList[2nd row][1st column];
ono2012
  • 4,967
  • 2
  • 33
  • 42
Nandu PH
  • 145
  • 1
  • 4
  • 10

5 Answers5

26

Try This

myvalue =dgvList.Rows[rowindex].Cells[columnindex].Value.ToString();
Pradnya Bolli
  • 1,915
  • 1
  • 19
  • 37
3
dgvList.Rows[INDEX].Cells[INDEX].Value
A G
  • 21,087
  • 11
  • 87
  • 112
1
dgvList[colIndex, rowIndex].Value
Lakewind
  • 29
  • 5
0
var myvalue =dgvList.Rows[columnindex, rowindex].Value;
Ramgy Borja
  • 2,330
  • 2
  • 19
  • 40
-1

how to display database value in dvg in dgv cell leave event

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()
Priya
  • 1,359
  • 6
  • 21
  • 41