How to get cell value from DataGridView in VB.Net?

前端 未结 5 1367
南旧
南旧 2021-01-06 19:54

I have a problem, how can i get value from cell of datagridview

----------------------------------
id     | p/w       | post       |
------------------------         


        
相关标签:
5条回答
  • 2021-01-06 20:29

    This helped me get close to what I needed and I will throw this out there for anyone else who needs it.

    If you are looking for the value in the first cell in the selected column, you can try this. (I chose the first column, since you are asking for it to return "3", but you can change the number after Cells to get whichever column you need. Remember it is zero-based.)

    This will copy the result to the clipboard: Clipboard.SetDataObject(Me.DataGridView1.CurrentRow.Cells(0).Value)

    0 讨论(0)
  • 2021-01-06 20:36

    In you want to know the data from de selected row, you can try this snippet code:

    DataGridView1.SelectedRows.Item(0).Cells(1).Value
    
    0 讨论(0)
  • 2021-01-06 20:36

    It is working for me

    MsgBox(DataGridView1.CurrentRow.Cells(0).Value.ToString)
    

    0 讨论(0)
  • 2021-01-06 20:43

    The line would be as shown below:

    Dim x As Integer    
    x = dgvName.Rows(yourRowIndex).Cells(yourColumnIndex).Value
    
    0 讨论(0)
  • 2021-01-06 20:51

    To get the value of cell, use the following syntax,

    datagridviewName(columnFirst, rowSecond).value
    

    But the intellisense and MSDN documentation is wrongly saying rowFirst, colSecond approach...

    0 讨论(0)
提交回复
热议问题